File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes JSP page in WEB-INF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP page in WEB-INF" Watch "JSP page in WEB-INF" New topic

JSP page in WEB-INF

Erik Pragt
Ranch Hand

Joined: Sep 08, 2001
Posts: 125
Hello all,
I have to (simple?) questions.
1) Is it possible to place to a jsp page in WEB-INF?
2) if the first question equals true, how do I create a new instance of that page using a servlet? (Or, in other words: how do I use that jsp page???)
Thanks for your help, if someone could help me, if would be great!
ashwin ram

Joined: Nov 19, 2002
Posts: 1
The J2EE Servlet 2.3 spec says that the WEB-INF node is not a part of the public document tree of an application and no file in this directory can be served directly to the client by the container. The spec does not seem to explicitly specify how to handle cases where a controller servlet or another JSP forwards a JSP page in the WEB-INF directory.
Some app servers like BEA Weblogic 7.0 do not serve up jsp pages from the WEB-INF directory either in response to a direct request from the client or when another JSP/servlet forwards to it. However I came across a book from Sun Press that seems to encourage users to put JSP pages in the WEB-INF directory that they didn't want the client to access directly but could be served up via a jsp/servlet forward.
In summary, you may be trying something that may not be portable across app servers. If your app server behaves like the latter case above, you can refer to the JSP page in the WEB-INF directory from a controller servlet using something like below
getServletContext().getRequestDispatcher("/WEB-INF/exampleFolder/example.jsp").forward(request, response);
Hope this helps.
-- Ashwin
I agree. Here's the link:
subject: JSP page in WEB-INF
It's not a secret anymore!