On Mon, 11 Jun 2001, JULIEN,TIMOTHY (HP-NewJersey,ex2) wrote:
> Does jasper have an architecture goal to run in other Servlet Containers?
In general, yes ... at least to the extent that the non-spec-related
dependencies are clear and easy to understand.
> I ask because I am working on a Servlet/JSP Container, and the JSP portion
> (a Servlet) has been kept separate for this exact reason. We would like our
> JSP implementation to be able to run in any Servlet Container, and we would
> like to run other JSP implementations in our Servlet Container.
>
> The obvious difficulty (and the reason for this message) is obtaining:
> -classpath information
> -classloader information
> -file system path to the JSP
> -many other pieces of information
>
Here's how the Tomcat 4 version of Jasper deals with these issues:
* Jasper assumes that the context class loader is the class loader for
this web app. This a pretty portable assumption today, and looks likely
to be included in the J2EE 1.3 final spec.
* If the web app classloader is a java.net.URLClassLoader (or a subclass
of that class), the "classpath" information can be inferred from the
list of repositories. Jasper also follows the parent class loader chain
upwards to discover other repositories that are available.
* The filesystem path of the document root for a web app does not
necessarily exist -- for example, when you are running directly out
of a WAR file. To detect things like changes to JSP pages that should
trigger automatic recompilation, Jasper assumes that the URL stream
handler provided by the servlet container allows things like this
to work correctly:
URL url = getServletContext().getResource("/index.jsp");
URLConnection conn = url.openConnection();
long lastModified = conn.getDate();
In general, we've tried to eliminate any dependencies on the internals of
Catalina (the servlet container part of Tomcat 4), or on the file system.
> It would be great if the JSP spec detailed where to put this information,
> i.e., in the request under known attribute names, but since this is not
> currently in place, i am interested in other options.
>
> Options I see:
> 1. All Servlet/JSP implementations using common:
> a) attribute storage (i.e., the request)
> b) attribute names (i.e., javax.servlet.jsp.classpath)
>
> This is probably a bit of a pipe dream since JSP implementations may expose
> attributes in different places.
>
> 2. Compile a list that details where attributes are stored (it may be
> several different places), and what their names are. Then, to achive
> pluggability, a filter could be written which maps the Servlet Container's
> attribute name/value pairs to the name value pairs the JSP implementation is
> expecting. This will be slower (a filter has to run for each request), and
> a bit of a hack, but it may be more acheivable then option 1.
>
Specifying this stuff would be useful if you wanted to try to have *all*
JSP containers be portable to *all* servlet containers, but that seems to
be somewhat aggressive -- and not necessarily optimal for a particular
container, because you can gain potentially large performance improvements
if your JSP container *can* make assumptions about the environment it runs
in (such as using the servlet container's class reloading capabilities).
> any thoughts?
> Tim Julien
> HP Middleware
>
Craig McClanahan