Weblogic has a slick way of doing this - you just set a flag in one of the deployment descriptor (xml) files, and it pre-compiles your JSPs when your app starts up! I wish Tomcat had a similar feature.
Do you use Ant and Tomcat? If so, I wrote this task this morning to pre-compile my JSPs. I'm putting these into my WEB-INF classes directory, but it doesn't seem to be working - maybe i should compile them right into $CATALINA_HOME/work/localhost/${webapp.name} <property environment="env"/> <!-- =================================================================== --> <!-- Pre-Compile JSP's --> <!-- =================================================================== --> <target name="jspc" depends="deploy"> <!-- Use tomcats jspc's program to precompile jsp's --> <echo message="Pre-Compiling JSPs..."/> <exec dir="${build.home}" executable="${env.CATALINA_HOME}/bin/jspc.bat" failonerror="on"> <arg value="-v3"/> <arg value="-uriroot"/> <arg value="${webapp.name}"/> <arg value="-d"/> <arg value="${webapp.name}/WEB-INF/classes"/> <arg value="-webapp"/> <arg value="${webapp.name}"/> </exec> <echo message="Compiling JSPs -------------------"/> <javac srcdir="${webapp.target}/WEB-INF/classes" destdir="${webapp.target}/WEB-INF/classes" debug="${compile.debug}" deprecation="${compile.deprecation}" optimize="${compile.optimize}"> <classpath refid="classpath"/> </javac> </target> Hope this helps, Matt --- Joseph Barefoot <[EMAIL PROTECTED]> wrote: > I'd like to go ahead and voice some thanks to anyone who can help me out on > this... > > Ok, I know that this has hit the list a few times before, and I've peered > into the mail-list archive (as well as my crystal ball) to figure this one > out, but I was wondering if someone could give me a little validation: > > We already have an existing application built on the Struts framework (works > great, woo-hoo!), but now we'd like to precompile the JSPs for production > purposes (current production uses non-precompiled JSPs). However, we'd like > to retain the ability to use non-precompiled JSPs for development purposes, > QA, etc. I understand how to precompile the JSPs, and they should reside (I > think) in the WEB-INF/classes folder. > > As I understand it, to enable precompilation with struts, one has to define > a servlet-mapping (for each JSP class) in the web.xml file, and then refer > to these mappings' <url-pattern> values in your <forward> tags within the > struts-config.xml. > > To switch between precompiled and non-precompiled JSPs, one would swap out > web.xml files (one w/ servlet mappings, another without), and switch your > build target to package either JSP pages or their corresponding compiled > classes. > > So, here's an example (as I see it) of using a precompiled JSP servlet > mapping w/ a Struts forward (let me know if this is wrong): > > <!-- From struts-config.xml --!> > > <forward name="new" path="/WEB-INF/jsp/common/login.jsp"/> > > > > <!-- From web.xml (assuming that login.jsp is compiled as > JspServ.login) --!> > > <servlet> > <servlet-name> > login > </servlet-name> > <servlet-class> > JspServ.login > </servlet-class> > </servlet> > > <servlet-mapping> > <servlet-name> > login > </servlet-name> > <url-pattern> > /WEB-INF/jsp/common/login.jsp"/ > </url-pattern> > </servlet-mapping> > > > /* code snippet utilizing the above forward ('mapping' is an instance of > ActionMapping): > > return( mapping.findForward("new")); > > */ > > > > So, is this the correct way to go about it? If so, will Struts still handle > forwards with appended URL parameters correctly, like this example? > > <!-- From struts-config.xml --!> > <forward name="confirmed" path="/login.do?confirmed=true" redirect="true" > /> > > > Does anyone have experience moving from non-precompiled JSPs to precompiled > ones, as we are trying to do here, and if so, are there any other "gotchas" > you know about or tidbits of knowledge you'd like to impart? :) > > Oh yeah, if I have all this completely wrong, do try and forgive me. :) > > > thanks so much, > > Joe > > > P.S. How slick would it be if the Struts framework had facilities for doing > this automatically? In other words, have a tag within the struts-config.xml > file that specifies precompilation: the precompiler class to use, the java > compiler class to use, class path, etc., and then the Action servlet would > handle forward requests by redirecting to the compiled JSP servlet instead > of the actual .jsp page. The Struts framework could maintain the mapping > between forward URLs specified in the struts-config.xml and the actual > compiled JSP servlet classes. You could even have options like "retainJSP", > which would determine whether JSP files would be deleted after compilation, > or retained on the file system. That would be super-cool!! > > > > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > __________________________________________________ Do You Yahoo!? Yahoo! Sports - Coverage of the 2002 Olympic Games http://sports.yahoo.com -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>