File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Problem: Struts+Modules+jsps under WEB-INF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem: Struts+Modules+jsps under WEB-INF" Watch "Problem: Struts+Modules+jsps under WEB-INF" New topic
Author

Problem: Struts+Modules+jsps under WEB-INF

Maciej Kolodziej
Greenhorn

Joined: Feb 11, 2002
Posts: 26
Hi,
I started developing an application with Jakarta Struts 1.1. I decided to build it using multiple modules (sub-apps) and also hide all jsps under WEB-INF. Thus my application structure looks like this:
app/img/
app/css/
app/WEB-INF/
app/WEB-INF/classes/
app/WEB-INF/lib/
app/WEB-INF/jsp/
app/WEB-INF/common/
app/WEB-INF/common/mainScreen.jsp
...
Now I create an action in stuts-config-common.xml and define it like this:
<action forward="/WEB-INF/jsp/common/mainScreen.jsp" path="/test"
scope="request" unknown="false" validate="false"/>
When I want to fire this action I have to type for ex.:
http://localhost:8080/app/common/main.do
But then I get a message:
type Status report
message /common/WEB-INF/jsp/common/mainScreen.jsp
description The requested resource (/common/WEB-INF/jsp/common/mainScreen.jsp) is not available.
So the module name is used as context(?) and put also before WEB-INF. Why? I don't need this. The module name should be put after jsp, as it is.
If I create another action test.do and put in in default module this doesn't happen.
--
MK
[ December 03, 2002: Message edited by: Maciej Kolodziej ]

MK
Ted Husted
Author
Ranch Hand

Joined: Dec 02, 2002
Posts: 37
Personally, I don't favor placing JSPs under WEB-INF. Some containers do not support this, and if you are linking to Actions rather than JSPs, they are already "hidden".
The module feature works by prepending the module name (or context) between the application context and the rest of URI. In the normal course, you should never embed the module name in URI, since Struts puts it there for you.
By default, all the JSPs and other resources should be placed under a directory named for your module context. If you want to place your resources under subdirectory, including WEB-INF, you can change the default configuration through the pagePattern property of the controller element in the struts-config.
In your case, I believe this would be
<controller pagePattern="/WEB-INF$M$P" />
which tells the Struts tags to insert "/WEB-INF" before the usual /commons/page.jsp
HTH, Ted.


<a href="http://husted.com/struts/book.html" target="_blank" rel="nofollow">Struts in Action</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem: Struts+Modules+jsps under WEB-INF