Quoting "Noel J. Bergman" <[EMAIL PROTECTED]>:

> Jeremy Boynes wrote:
> > Lyndon Samson wrote:
> > > The JSP PageContext.forward method takes a relative URI.
> > > However I'd like to forward control to an in-memory
> > > representation of a JSP rather than a URI backed by a
> > > file in the filesystem.
> 

Note that relative URIs just get resolved against some absolute base URI, so at
the end of the day it still comes down to ensuring that the appropriate
URLStreamHandler is invoked.

> > Isn't that a servlet mapping, where your "in-memory JSP"
> > is really a servlet?
> 
> The Servlet/JSP container is responsible for loading/unloading as necessary.
> As a general rule, the servlet class would be memory resident once invoked.
> 
> > > A CMS for example may want load its JSP pages from a
> > > DBMS rather than the filesystem.
> 
> Orthogonal issue.  Not sure where tomcat would have the best hook for that,
> since I have not looked, but perhaps a Valve.  Craig would probably be the
> best person to ask.  It is not something in the Servlet Specification.
> 

<delurk>

There is definitely nothing portable in how one might add this facility to any
arbitrary servlet container, but Tomcat's foundation should be useful to you
(if
you're using Tomcat) or the basis for some ideas if not.

Basically, Tomcat models the static resources of a web application as a JNDI
DirContext, with nested DirContext objects for nested "directories" in the WAR. 
Out of the box, two implementations are included -- one for running webapps out
of an unpacked directory on disk, and one for running webapps directly from a
WAR without unpacking it first.  All the access details (including the ability
to create URLs for things like ServletContext.getResource(), and then resolve
them, is hidden inside these implementations.  That allows, for example, the
default servlet that serves static resources to have no idea how the bits for a
particular static resource are actually acquired.  Among other things, it also
allows Tomcat to transparently provide some performance enhancing tricks, such
as caching resources smaller than a configurable size in memory so you don't
have to hit the disk every time that resource is requested.

Writing a third implementation that represented the static resources as objects
in a database (or a directory server, or an in-memory object graph, or ...)
would be fairly straightforward.  But implementing it would definitely be
Tomcat
specific.  I don't know if Jetty has a similar abstraction approach for access
to webapp resources, but I'm sure Greg will be able to answer that.

For use outside the context (pardon the pun :-) of a servlet container, the
Apache Directory project is working on abstracting the JNDI stuff out of Tomcat
and making it a generally reusable component as well.  That project is
currently in incubation (as is Geronimo):

  http://incubator.apache.org/projects/directory.html

</delurk>

>       --- Noel
> 

Craig McClanahan

Reply via email to