• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP Precompile

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can i precompile jsp using Ant and tomcat
 
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All jsp's will convert to (servlet) java code on calling jsp in a folder called 'work' which is present in tomcat root folder.
Is it what you wanted. Else post back with more detail regarding the problem
-arun
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Part of the JSP spec is to implement jsp precompilation from a URL: http://host/app/page.jsp?jsp_precompile=true -- maybe you can create a script that will run that URL for you -- or some app server vendors provide a .bat file that will run precompilation, maybe you can create an ant script that will call that bat file for you...
 
Sridhar Raman
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What i wanted to know is using Ant you can compile java files, jar it war it create ear and also deploy it. but is there a way to use ant script and compile jsp code also
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sridhar Raman:
What i wanted to know is using Ant you can compile java files, jar it war it create ear and also deploy it. but is there a way to use ant script and compile jsp code also


Not built into it natively, no. Because JSP Precompilation is vendor dependent -- the resultant java servlet will have the vendor's code written in it, so Ant can't do it itself.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you can use the jspc task in ant to precompile your jsp files into .java files. You can also postcompile those .java files into .class files. Read this link: http://ant.apache.org/manual/OptionalTasks/jspc.html
However, I'll warn you that jspc will create the proper directory structure including subdirectories, but it doesn't put subdirectory information into the .java package declaration. Everything is stuffed into a single package. This means that if you have
maindir/subdir1/index.jsp
and
maindir/subdir2/index.jsp, you'll end up with 2
index_jsp.java files which BOTH have package
maindir. subdir1 and subdir2 won't be put into the package name.
If anyone knows how to get around this, please shout!
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
For security purpose, I have tried many time to make a pre-compile of JSP to be able to remove all *.jsp file leaving only *.class files. But I never made it work.
I am using Tomcat 4.1.xx and it automaticaly compile everything in the work folder. All jsp file is translate in java in an "org.apach.jsp package", even if the jsp page is in a sub-folder of the root.
The problem about the ANT jspc is that it translate the page in another package bellow the "org.apache.jsp" one. I think that is a reason why tomcat cannot find its JSP classes.
The other problem I face is that I put all jsp in the WEB-INF/jsp folder because I use Struts and I dont want my jsp page to be see directly (only via a Controller Servlet see MVC). The jspc compiler will put all my jsp in the org.apache.jsp.WEB_0002dINF.jsp folder... this doesn't help I guess.
ANY CLUE ANYONE ?
See : ANT JSPC to have more info
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some servers like weblogic allow for precompilation of JSP.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch Dave P!
You'll find this forum a great place to seek help on JSP pages, and there
aren't many rules you'll have to worry about, but one is that proper names
are required. Please take a look at the
JavaRanch Naming Policy and
change your display name to match it.
Thanks!
bear
JSP Fourm Bartender
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I was able to precompile the jsp's into .class files .
I have used the jspc and javac tasks.
Now should I move them into the work dir of tomcat
pls suggest the next step.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having the same problem as mentioned by E Laverdiere. John how did you make it work? Please let us know.Thank you
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic