File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ant task to compile JSP

 
Deepak Jain
Ranch Hand
Posts: 637
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I was testing ant with JSP compilation.
My JSPC task is defined as follows

<!-- *********************************************************************
* jspc - Compile JSP files.
********************************************************************** -->
<target name="jspc" description="Compile JSP source." depends="init">
<path id="jspc.ref.classpath2">
<pathelement path="${env.CLASSPATH}"/>
<pathelement location="${TESTPROJECT.src}"/>
<pathelement location="${TESTPROJECT.build.classes}"/>
<pathelement location="${src}"/>
<pathelement location="${build.classes}"/>
<fileset dir="${TESTPROJECT.lib}" includes="*.jar"/>
<fileset dir="${ant.home}/lib" includes="*.jar"/>
<fileset dir="${TESTPROJECT.build.lib}" includes="*.jar"/>
<fileset dir="${build.lib}" includes="*.jar"/>
</path>

<!-- *********************************************************************
* JSP compile: ROOT
********************************************************************** -->
<compile-jsp name="ROOT" uriroot="${maven.src.main.jsp}/ROOT"
outputdir="${build.jspc_base}/_" />

</target>
Error:
jspc:
[echo]
[echo] ROOT [jsp->java->class]
[echo] [jsp->java] Compiling jsp source to java source...
[java] - Internal Error: File /WEB-INF/web.xml not found
[java] org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files de ployed with this application
[echo] [java->class] Compiling java source to java bytecode...

Please let me know how i can get it working.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's expecting you to provide a WEB-INF/web.xml file that itself refers to the tag library http://java.sun.com/jsp/jstl/core.
 
Deepak Jain
Ranch Hand
Posts: 637
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The tag library http://java.sun.com/jsp/jstl/core is defined by JSTL library. How can i include the library in the ANT file.
 
Vijitha Kumara
Bartender
Posts: 3908
9
Chrome Fedora Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepak Jain wrote:The tag library http://java.sun.com/jsp/jstl/core is defined by JSTL library. How can i include the library in the ANT file.


Are the JSTL jar files (standard.jar & jstl.jar) in your classpath ? Normally this is what required for compiling the JSPs.
 
Deepak Jain
Ranch Hand
Posts: 637
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thought so, but your reply was a trigger to actually try that. It has fixed part of the error.
Now i see the following error
[java] - Internal Error: File /WEB-INF/web.xml not found

where as earlier i used to see

[java] - Internal Error: File /WEB-INF/web.xml not found
[java] org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files de ployed with this application

Now the JSP's are compiling into Java classes.
How do i avoid the below error
[java] - Internal Error: File /WEB-INF/web.xml not found


 
Vijitha Kumara
Bartender
Posts: 3908
9
Chrome Fedora Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now i see the following error
[java] - Internal Error: File /WEB-INF/web.xml not found


That's may be you haven't specify the webxml attribute, which is not required actually (I haven't tried it though) ... But jspc is deprecated here.


jspc (deprecated)

Deprecated if you use this task with Tomcat's Jasper JSP compiler, you should seriously consider using the task shipping with Tomcat instead. This task is only tested against Tomcat 4.x. There are known problems with Tomcat 5.x that won't get fixed in Ant, please use Tomcat's jspc task instead.
 
Deepak Jain
Ranch Hand
Posts: 637
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its a huge project that am working on and i don;t have control of changing ANT itself. Infact am having tough time to convincing people to use JSTL and scriptless-FREE JSP pages, I am the one who is putting all the effort and still guys are not ready to use JSTL and approach of Script-free pages.

How should specify webxml attribute? Can you please edit the JSPC task that i had shared with the post.
Thanks a lot for your reply, to be honest i wasn;t expecting any replies.
 
Vijitha Kumara
Bartender
Posts: 3908
9
Chrome Fedora Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepak Jain wrote:Its a huge project that am working on and i don;t have control of changing ANT itself.


What you mean by that? Changing your build.xml or ant libraries? If the latter, I don't think it's necessary.

How should specify webxml attribute?


Check the documentation and try it . BTW why are you compiling the JSPs yourself?
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vijitha Kumara wrote:
Deepak Jain wrote:Its a huge project that am working on and i don;t have control of changing ANT itself.


What you mean by that? Changing your build.xml or ant libraries? If the latter, I don't think it's necessary.

How should specify webxml attribute?


Check the documentation and try it . BTW why are you compiling the JSPs yourself?


I can only assume he wants to precompile the JSPs to get any warnings early and/or deliver precomipled JSPs to the web server (some web servers compile the first time you hit the page which makes for bad user experience).
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic