You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Matthew Hughes <ma...@gmail.com> on 2005/02/16 23:48:55 UTC

Strategies for Large Struts Application (LONG)

I inherited a rather large Struts application a couple of months ago. 
It was rather badly organized and almost no test code exists for
either the business code or Actions. One of the many problems I have
working with this code is that all the Action classes (200+) exist in
one flat package with no consistent naming structure.  The JSPs (200+)
also all sat in one flat folder with no consistent naming structure
either.

Recently, I have begun the frustrating (but
worth-it-in-the-long-run-...I hope) process of splitting the
application into more manageable parts.  I created an extensive
use-case list and seperated them into about eight clusters.  I created
a folder for each cluster and put the JSPs into their respective
folder.  It took a lot of work to get that together and fix the
struts-config. All the links from one JSP to another work if you go
through an Action first, but if you go directly to the JSP, a lot of
links fail.

My structure is sort of like this:

webapp\jsps\similarActions1
webapp\jsps\similarActions2
webapp\jsps\similarActions3

webapp\images
webapp\css
webapp\js

What is the best solution?  Put a <base href=""> tag on every page, or
insert the context path before every link, image source, frame source.
 OR I have an idea of using JavaScript to just parse through all the
links, image sources, and prepend the context path.  Anyone who has
had trouble with relative links and links breaking when you move stuff
around, I'd be happy to heard your thoughts on this.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Strategies for Large Struts Application (LONG)

Posted by Illya Kysil <ik...@ua.fm>.
Matthew Hughes wrote:
> ...[large section removed]...
> 
> What is the best solution?  Put a <base href=""> tag on every page, or
> insert the context path before every link, image source, frame source.
>  OR I have an idea of using JavaScript to just parse through all the
> links, image sources, and prepend the context path.  Anyone who has
> had trouble with relative links and links breaking when you move stuff
> around, I'd be happy to heard your thoughts on this.
I have developed a project of similar size in the past. I recommend the 
following (apply in sequence):
1. Replace ALL <a href="..."> tags with <struts-html:link> tags. This 
will allow you to use HREFs relative to webapp root (context) only. See 
Struts Taglib documentation for further details.
2. Replace ALL links going to JSPs with links going to actions which 
forward requests to configured JSPs in turn. The Action code is trivial:
   public ActionForward execute(ActionMapping mapping, ActionForm form,
   HttpServletRequest request, HttpServletResponse response)
   throws Exception{
     return mapping.findForward("success");
   }
You just need to configure a separate action for each distinct link.
This will allow you to keep all JSP references in one file.
3. It would be better to move JSPs under WEB-INF folder for security 
reasons.

-- 
Illya Kysil, software developer
Java/Delphi/C/C++/C#/Forth/Assembler
-------------------------------------------------------------------------
Shakespeare / King Henry IV
GLENDOWER  I can call spirits from the vasty deep.
HOTSPUR    Why, so can I, or so can any man;
            But will they come when you do call for them?


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org