Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to preload a JSP?

 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • 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?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
paritosh ranjan
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • 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 Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
I am using apache-tomcat-5.5.23
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pass the pre_compile parameter were?
What file is this in?
 
paritosh ranjan
Ranch Hand
Posts: 62
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65227
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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 Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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 Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
H. Hall
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic