Gregor Schneider wrote: > Len, > > agreed to the most of what you said, however, I still do not see why > JSPs have to go (or should go) into WEB-INF. > > Even in this tutorial (linked directly fom java.sun.com) > http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/ the JSP-file goes > directly into the app-dir where also the static HTML resides. > > On Mon, Mar 9, 2009 at 8:23 PM, Len Popp <len.p...@gmail.com> wrote: > >> What I mean is, clients *never* access a .jsp file by URL, e.g. >> "http://www.example.com/app/foo.jsp". >> > > This is definately wrong. When you call a jsp directly from within a > Servlet-Container, the file gets compiled to a servlet and the output > of the servlet is displayed. > > I've googled for this issue, and what I find, is, that some frameworks > recommend putting JSPs into WEB-INF/jsp. > However, I also found the statement that not all Servlet-Containers > are supporting it. > > Now I'm wondering ("Mr. Servlet-Spec" Chuck, you comment on that one): > > Is this directory-structure really part of the specs? > > I just found this recomendation in context with frameworks like Struts > or Spring. > > I'm wondering: > > How does Tomcat find a JSP within WEB-INF/jsp? Do I have to specify it > in the deployment-descriptor? > > Rgds > > Gregor > I've done this trick before. It works very well if you have a lot of jsp includes, each providing it's own templating functionality. In that case, you don't want the client to have direct access to those jsp files providing only parts of the overall page. Or maybe you want to be sure a servlet mapping handles the request in MVC style before passing on the request to the view via an internal forward. Either way, it helps protect the webapp from clients calling jsps out of the context they were designed for.
The servlet container probably just uses something like the servlet context's getResourceAsStream() to find the file, then compile it and make it available. I've never needed to do anything special in WEB-INF/web.xml or any other config file to let tomcat know to find them there. Just use the jstl tag <c:import url="/WEB-INF/jsps/myJspFile.jsp" /> and it's done. --David --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org