>> OK, but how could that be done in a servlet rather than with JSP?
Thou knows how to read text resources (ServletContext.getResource on
"/WEB-INF/...")? Thou knows how to write text out to the servlet response?
> You should separate the model components into logic classes called
> directly or indirectly from a controller servlet that forwards the view
> to JSPs.
One doesn't have to use JSPs. There are plenty of template systems out
there. One doesn't have to use these either.
JSPs do make it easy to start with a page designed in HTML - one only
need to change the extension. For a complicated site one would want to
end up with Java code ("a servlet") writing to a SAX-like interface.
Adding "scriptlets" to the JSP takes you on a nice path between the two
extremes. JSP tags actually takes you down a blind alley.
Tom Hawtin
pepito188@gmail.com - 11 Aug 2007 15:37 GMT
> > pepito...@gmail.com wrote:
>
> >> OK, but how could that be done in a servlet rather than with JSP?
>
> Thou knows how to read text resources (ServletContext.getResource on
> "/WEB-INF/...")? Thou knows how to write text out to the servlet response?
Yes I know how to do that, but first of all, my resources are static
html pages, so they are not stored under WEB-INF. I was wondering if
there exists an easy way to do that avoiding reading files, in a
similar way that RequestDispatcher does.
Thomas Hawtin - 11 Aug 2007 16:15 GMT
>>> pepito...@gmail.com wrote:
>>>> OK, but how could that be done in a servlet rather than with JSP?
[quoted text clipped - 5 lines]
> there exists an easy way to do that avoiding reading files, in a
> similar way that RequestDispatcher does.
There's no reason why static pages should not be stored under WEB-INF.
Anything that is not directly accessible should be in that directory
(unless it's a static web site, that should usually be everything apart
from META-INF).
If thou wants to go all the way back through the servlet mechanism, thou
should be able to use getRequestDispatcher multiple times. Beware that
this will not necessarily treat the files as static. When one uses
<jsp:include page="..."> as opposed to <%@ include file="..."> the JSP
is compiled to use getRequestDispatcher multiple times (one can probably
look at the source intermediate code depending upon implementation).
Tom Hawtin