tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Malcolm Warren <malc...@villeinitalia.com>
Subject Re: Of .war and .jar files - and .jsp class files
Date Thu, 01 Apr 2004 09:04:21 GMT
Dear QM,

Just a footnote to this problem, if you're interested.
The difference between Tomcat and Jrun on this problem of packing up the 
automatcally-generated .class files for .jsps is considerable, and I have 
to say that in this case Jrun looks more logical. With Tomcat, as you have 
explained, in order to get it to work you have to create all the servlet 
mappings.

This wasn't necessary in Jrun, because you simply put a .jar file in place 
of the unpacked classes, and the servlet container had no trouble finding 
them, because the .jar file was in exactly the same place as the unpacked 
.class files.

For some reason there isn't this easy relationship between the location of 
the tomcat-generated .class files and the path through the file system. 
The automatically generated .class files in Tomcat are in the 
org.apache.jsp package, but the folders /org/apache/jsp aren't there in 
the file system, if you see what I mean. It would have been nice if the 
package logic had been followed through.

Regards,
Malcolm Warren



On Wed, 31 Mar 2004 09:50:41 -0600, QM <qm300@brandxdev.net> wrote:

> On Wed, Mar 31, 2004 at 02:55:16PM +0200, Malcolm Warren wrote:
> : Now when I transfer everything to my production server I would like to
> : eliminate all of the .jsp pages from the application, and all of the 
> .java
> : files, and just send a .jar file containing the .class files in
> : /work/Standalone/localhost/$applicationDir.
>
> You can do this.
> Sort of.
>
> That's what precompilation is all about.
> Please bear with me:
>
> - JSPs get compiled down to servlets, either by you (precompiling) or by
>   the container (at runtime).
>
> - when the container compiles a JSP for you, it takes care of mapping
>   the servlet to the context-relative URI that matches the JSP. So
>   /x/y.jsp is mapped, behind the scenes, to some.package.x.y_jsp.class.
>
>   To precompile the JSPs means you must tell Tomcat yourself which
>   classes map to given URIs.  Hence the autogenerated file full of
>   <servlet> and <servlet-mapping> entries I described in my last
>   message.
>
> - When you precompile, you have can even put the classes into a jar file,
>   but that jar file must be in {dist}/WEB-INF/lib.  That's the only way
>   Tomcat's classloader will find the jar.
>
> - With the JSPs compiled down to code, and properly mapped in web.xml,
>   you can remove the JSPs from your app.
>
> See
>
> 	http://jakarta.apache.org/tomcat/tomcat-5.0-doc/printer/jasper-howto.html#Web%20Application%20Compilation
>
> for more details on the precompilation process (assuming TC5).  It
> mentions the generated web.xml fragment of which I spoke.
>
>
>
> : That way the compilation is already done, and nobody can study my .jsp
> : files. In theory I could just create a directory tree somewhere of
> : org/apache/jsp/ copy all the automatically generated .class files into
> : this directory tree and .jar it all up, and Tomcat should find them 
> either
> : in /WEB-INF/lib or in /work/Standalone/localhost/$applicationDir, but 
> it
> : doesn't.
>
> Close, except that the jar of JSPs must exist in {dist}/WEB-INF/lib.
> Tomcat won't load a jar from the context dir itself, aka
> ".....//localhost/$applicationDir."  Just not how Tomcat works. ;)
>
> -QM
>



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message