• 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

How to preload a JSP?

 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did a search and couldn't find anything that seemed straightforward to preload a JSP when server starts...

Was thinking about creating a servlet called JspStarter to preload the JSP as it's easy enough to call a servlet at server startup - or is there a simpler way?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You were searching with the wrong keywords.
I think the term you're looking for is 'precompiling' or 'pre-compiling'.
http://www.google.com/search?q=precompiling+jsps&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i think you will have to pass the parameter jsp_precompile=true for precompiling that jsp without executing it along with the URL
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by paritosh ranjan:
i think you will have to pass the parameter jsp_precompile=true for precompiling that jsp without executing it along with the URL



Precompilation of JSPs is not spec driven, so, if you are going to recommend settings, it would be good if you would also tell us exactly what container and version you are using.
 
paritosh ranjan
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using apache-tomcat-5.5.23
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pass the pre_compile parameter were?
What file is this in?
 
paritosh ranjan
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://localhost:8080/chapter11/implicit.jsp?jsp_precompile=true
 
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
Your URL, pointing to localhost, is useless to anyone but you.
 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
He was demonstrating how to use the precompile parameter.

It didn't quite hit the nail on the head anyway. The solution I've found was to add to WEB-INF/web.xml file:

<servlet>
<servlet-name>login</servlet-name>
<jsp-file>/login.jsp</jsp-file>
<load-on-startup>1</load-on-startup>
</servlet>

Haven't tried it yet. Will be back if it doesn't work...
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My point to paritosh is that this is not spec driven, and thus different for every container. Because of this, it makes no sense to start giving directions for one container before finding out from the original poster, which they're using.

Since everyone here seems to be talking about Tomcat, I'm going to move this to our Apache / Tomcat forum.
 
paritosh ranjan
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ben

As you said
"I think the term you're looking for is 'precompiling' or 'pre-compiling'."

So I just tried to help in pre compiling the jsp.

I didn't knew that it was container specific.
This is one thing that I learned from this discussion.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by paritosh ranjan:
Ben

As you said
"I think the term you're looking for is 'precompiling' or 'pre-compiling'."

So I just tried to help in pre compiling the jsp.

I didn't knew that it was container specific.
This is one thing that I learned from this discussion.



It would be nice if there was a simple, spec driven way to force pre-compilation of all JSPs (without having to map them all in web.xml) when the container starts up but, alas, there isn't.

Thanks for your help.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about using the jspc utility (jsp compile)?

This is a script provided by Tomcat for precompiling jsps. To execute, supply the name of the JSP you wish to compile, e.g:

# $CATALINA_HOME/bin/jspc.sh $CATALINA_HOME/webapps/myFile.jsp

An equivalent .bat file is provided for Windows users.

Use a script or Ant to compile all jsps in a directory.

By the way, Tomcat 6 provides the ability to serve up the old version of a jsp until it compiles the new version.

You may want to read this:
Apache Tomcat 6.0 Jasper 2 JSP Engine How To

Scroll down to "Web Application Compilation"

Cheers
 
Catch Ernie! Catch the egg! And catch this tiny ad too:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic