tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Priest <Robert.Pri...@bentley.com>
Subject RE: Precompiling JSPs
Date Wed, 18 Jun 2003 14:51:48 GMT
You should read up on the JspC task:
http://ant.apache.org/manual/OptionalTasks/jspc.html

The JspC task will compile your jsp file to a java servlet (.java) file.
Then you can run <javac/> to get your class files.
You will need to download the jasper-compiler.jar and jasper-runtime.jar
files.
I currently do this in ant: 

Here is what my project for compiling my jsps looks like:

<project name="PW_JSPS" default="build" basedir=".">
 <target name="build">
 <property name="JSP_ROOT" value="${WEB_MAIN}/src/java/jsp"/>
 <property name="JSP2JAVA_DIR" value="${WEB_OUT}/jsp2java"/>
 
 <mkdir dir="${JSP2JAVA_DIR}"/>

 <echo
message="*******************************************************************
"/>
 <echo message="    Building\Compiling JSP files:" />
 <echo
message="*******************************************************************
"/>
 
  
  <jspc 
      srcdir="${JSP_ROOT}"
      destdir="${JSP2JAVA_DIR}"
      uriroot="${JSP_ROOT}"
      package="com.myproj.web.jsp"
      verbose="9"
      webinc="${JSP2JAVA_DIR}/generated_webxml_snippet.xml">
  <include name="**/*.jsp" />
   <classpath id="jsp_classpath">
      <pathelement path="${env.CLASSPATH}"/>
      <path refid="classpath"/>
      <pathelement
location="${TOMCAT_SOURCE}common/lib/jasper-compiler.jar"/>
      <pathelement
location="${TOMCAT_SOURCE}common/lib/jasper-runtime.jar"/>
    </classpath>
</jspc>

  <javac srcdir="${JSP2JAVA_DIR}" destdir="${WEB_OUT}"
     includes="**/*.java"
     listfiles="yes"
     debug="${turn_on_debug}"
     classpathref="jsp_classpath"
     />

 </target>
</project> 

-----Original Message-----
From: Andy Eastham [mailto:andy.eastham@gliant.com]
Sent: Wednesday, June 18, 2003 10:37 AM
To: Tomcat Users List
Subject: RE: Precompiling JSPs


Andoni,

I do this in Sun One Studio, where I do all my Java development.

You can compile JSPs just as you can compile java source.

Andy

> -----Original Message-----
> From: Andoni [mailto:andoni@indigo.ie]
> Sent: 18 June 2003 10:25
> To: Tomcat Users List
> Subject: Precompiling JSPs
> 
> 
> Hello,
> 
> I have a build.cmd file that I have had and modified for every 
> project I've done for years.  I should probably go learn ANT or 
> some other build technique but for now I want to do this the 
> command line way.  I'm not even sure if ANT will do what I want.
> 
> I want to have my .jsp files made into .java files (easy) then 
> compiled into .class files (hard) before starting my Tomcat.  
> That way I can see any syntax errors in my .jsp files.
> 
> If I do this at the moment I get a load of errors where one JSP 
> which is included in another uses variables which are only 
> declared in the major one.
> 
> Is there a way to compile the .java files the way Tomcat does 
> (which takes account of included .jsp's)?
> 
> Does ANT create .class files?
> 
> Thanks in advance.
> 
> Andoni.


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

---------------------------------------------------------------------
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