Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP compilation

 
Phillipe Rodrigues
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a query.

When we run a jsp page for the first time it takes time to execute as the jsp turns into servlet(that is translation and compilation).Now if do some changes in the jsp and with out restarting the serfer does the same translation and compilation take place.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.
The container compares the JSP and generated servlet's class file with each request and recompiles the JSP if it is new.

Note: Some containers can be configured to disable this in production environments, for performance and/or security reasons.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might be interested in this article.
 
sreejith sree
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
tomcat will constantly moniter the java server pages deployed in the web-inf directory for changes.

when ever a new page is requested, every time , jsp page will compile to corresponding servlets , a java class file , and dump the output as raw html,

you can change the jsp at run time , but cant change the servlet class at run time , i think, i want to work on this matter ,
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by sreejith sree:
tomcat will constantly moniter the java server pages deployed in the web-inf directory for changes.

when ever a new page is requested, every time , jsp page will compile to corresponding servlets , a java class file , and dump the output as raw html,

you can change the jsp at run time , but cant change the servlet class at run time , i think, i want to work on this matter ,


A few corrections.
There is no "web-inf" directory.
Java is a case sensitive language and that directory is spelled "WEB-INF".
This might sound like nit picking but it throws a lot of beginners off so I point this out whenever I see it.

when ever a new page is requested, every time , jsp page will compile to corresponding servlets , a java class file , and dump the output as raw html,


This is not true.
JSPs are only compiled to servlet code once in the life of the application unless the JSP file has been altered. The output, is not necessarily HTML.

Also, many containers have settings to automatically reload the app if any class files are updated. Tomcat does this with the autoReload attribute of the Context entry. With Tomcat, you can also configure it to watch any file for changes and automatically reload the application. I believe Resin can be configured to watch Java source files and automatically compile them with an app reload when they change.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic