Hello everybody, I know it is a little off-topic, but I thought I'd share this anyway since it might help people a lot.
I have always found it unnatural for enterprise application to deploy code that would still need to be compiled at runtime, I am thinking about JSPs not Velocity (which is interpreted). Think about it, you put your JSPs on the server, the server lazily compiles them into Java files which are then compiled into classes. A lot of work that can easily be avoided. What I am going to describe next is a way to include those final classes into your WAR bundle instead of the regular JSPs. I just succeeded in doing so and noticed a tremendous performance increase; also, this time JSPs are compiled during development which means it is easier to spot possible compilation problems. You don't want to click and wait for each page at runtime to see if they show or not. The idea is probably so simple that not too much people really thought about it. 1. JSP --> Java You will need to use the JSP compiler from a JSP/Servlet container in order to compile the JSPs into Java code, I used org.apache.jasper.JspC from the tomcat jasper-compiler-4.0.4.jar bundle (also need jasper-runtime-4.0.4.jar) 2. Java --> Classes Simply compile the generated classes into bytecode, you will need to put all the classes from your /WEB-INF/lib into the classpath (Struts, Servlet, ...) 3. WAR but all those classes either in /WEB-INF/classes or bundle them in a jar and put the jar in /WEB-INF/lib, these classes are the servlets 4. web.xml one thing remains, since your code still refers to JSPs you will need to explain somehow which JSP corresponds to which servlet, well, the org.apache.jasper.JspC can also generate a piece of XML with web.xml directives, you will need to merge it with your original web.xml 5. ready to deploy deploy that puppy into your container, sit back and smile (to be honest, I still have a small issue where the welcome file is not picked up for some reason, so I have to type http://127.0.0.1:8080/project/index.jsp manually instead of only http://127.0.0.1:8080/project/) here is an Ant snippet that'll do the job <echo message="Generating Java sources from JSPs"/> <java classname="org.apache.jasper.JspC" fork="true" classpathref="classpath"> <arg value="-d"/> <arg value="${jspc.output.java}"/> <arg value="-webinc"/> <arg value="${jspc.output.webxml}"/> <arg value="-webapp"/> <arg value="${jspc.input.webapp}"/> </java> optionally you can use the -p argument to generate into a subdir, read the jasper docs for more info jspc.output.java=where jspc puts the generated java files (dir) jspc.output.webxml=where jspc puts the generated web.xml directives (file) jspc.input.webapp=where YOU will put your exploded WAR file (dir) it seems the order of the arguments is important so after that compile the java sources, put them in /WEB-INF/classes, remove the JSPs (!), merge web.xml and bundle your war again while I'm at it, you merge like this: <!-- merging additional web.xml directives --> <echo message="Merging additional web.xml directives"/> <loadfile property="directives" srcFile="${jspc.output.webxml}"/> <replace file="${jsp.input.webapp}/WEB-INF/web.xml" value="${directives}" token="<!-- precompilation merge-point -->"/> I have a line after the last servlet declaration in my web.xml: <!-- precompilation merge-point --> it will be replaced by the generated directives btw, in my classpath I have: servletapi 2.3 struts 1.1 jasper-compiler 4.0.4 (tomcat) jasper-runtime 4.0.4 (tomcat) commons (collections, beanutils, digester and logging) I hope this helps, it will surely have a good impact on performance, trust me. best regards Wouter. __________________________________________________________________ McAfee VirusScan Online from the Netscape Network. Comprehensive protection for your entire computer. Get your free trial today! http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397 Get AOL Instant Messenger 5.1 free of charge. Download Now! http://aim.aol.com/aimnew/Aim/register.adp?promo=380455 ------------------------------------------------------- This SF.Net email sponsored by: ApacheCon 2003, 16-19 November in Las Vegas. Learn firsthand the latest developments in Apache, PHP, Perl, XML, Java, MySQL, WebDAV, and more! http://www.apachecon.com/ _______________________________________________ Andromda-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/andromda-user
