Jsp to Servlet converter

Here is the Ant build file to convert jsp file to servlet file.
jspc (JavaServerPages Compiler) tool is helping to convert the jsp. The requirements are you need
- java sdk
- apache tomcat
- ant
The build.xml is
<project name="Test" default="compile" basedir=".">
<description>
JSP to Servlet Converter
</description>
<property name="name" value="JSP to Servlet" />
<property environment="env" />
<property name="ANT_HOME" value="${env.ANT_HOME}" />
<property name="TOMCAT_HOME" value="D:\server\Tomcat 5.5" />
<target name="init" description="Initialization" >
<path id="tomcat.classpath">
<fileset dir="${TOMCAT_HOME}\common\lib">
<include name="*.jar" />
</fileset>
</path>
<path id="ant.classpath">
<fileset dir="${ANT_HOME}\lib">
<include name="*.jar" />
</fileset>
</path>
<path id="webapp.classpath">
<fileset dir=".\WEB-INF\lib">
<include name="*.jar" />
</fileset>
</path>
</target>
<target name="compile" depends="init" description="compile the source" >
<mkdir dir="./out" />
<jspc srcdir="."
destdir="out"
verbose="9">
<classpath>
<path refid="tomcat.classpath" />
<path refid="ant.classpath" />
<path refid="webapp.classpath" />
</classpath>
<include name="*.jsp" />
</jspc>
</target>
<target name="build" depends="compile"/>
<target name="clean" description="clean the directories">
<delete dir="./out" />
</target>
</project>
No related posts.
Just what I wanted. Nice work.
But, I am a little unclear how to set up this script. I have tried this previously from eclipse but the right jasper compiler classes are just too hard to find.
Step by step instructions are very much appreciated.
Hi ilango,
here the stpes
1. place the build.xml where your jsp files are there..
2. change this property ANT_HOME to your ant path or set environmental value for ANT_HOME
3. do the same above for TOMCAT_HOME
4. Now go to your command prompt then “ant build.xml”
5. Thats all .. now your converted java files in out folder.