• 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 turning into Servlet

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,

according to the concept behind JSP's when the JSP is called from a browser or run from a browser the JSP gets turned into a servlet and it keeps it in the memory and uses the same instance of the servlet for the future calls for the jsp page.. this means if u do any changes to the jsP it shouldnt reflect on the screen provided u dont restart the server... but this doesnt happen this way.. when u change the jsp and without restarting the server it changes the page ,, why is this? is this something to do with some features of the container? i'm using Apache Tomcat..
 
author
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, a JSP page is converted into a servlet at request-time.

Moreover, the JSP spec requires the web container (Tomcat) to recompile the JSP into a servlet whenever the JSP file changes. This spec requirement supports the goal of rapid prototyping during development.

Cheers,
Bryan
 
Charith Fernando
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks.

summary would be... if u change a jsp page while the server is running it destroys the current instance of the jsp and makes a new one.. but for servlets it uses the same old instance..
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Weblogic I need to set
<context-param>
<param-name>weblogic.httpd.servlet.reloadCheckSecs</param-name>
<param-value>-1</param-value>
</context-param> in web.xml and
<jsp-param>
<param-name>pageCheckSeconds</param-name>
<param-value>-1</param-value>
</jsp-param> in weblogic.xml

I am not sure about Tomcat...
 
Aneesh Kumar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Weblogic I need to set
<context-param>
<param-name>weblogic.httpd.servlet.reloadCheckSecs</param-name>
<param-value>0</param-value>
</context-param> in web.xml and
<jsp-param>
<param-name>pageCheckSeconds</param-name>
<param-value>0</param-value>
</jsp-param> in weblogic.xml

I am not sure about Tomcat...
 
Bryan Basham
author
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Charith Fernando:
Thanks.

summary would be... if u change a jsp page while the server is running it destroys the current instance of the jsp and makes a new one.. but for servlets it uses the same old instance..



Yes, this is a good summary.

The servlet spec also includes a provision for the web container to monitor when servlet .class files change and to reload these servlets dynamically. In that situation, the old servlet instance is destroyed and then the web container loads the new class, creates an instance, initializes the servlet instance, and then makes it ready to recieve new requests. This mechanism (which is virtually identical to the JSP reloading mechanism) is optional in the spec so not every container supports this mechanism. I believe that Tomcat supports servlet class reloading, but I have not personally tried it.

HTH,
Bryan
 
Charith Fernando
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
wow.... i never knew that..i always restarted tomcat when i do some servlet changes and put the classes in...

does this mean that if i get a question in the exam related to this i should answer thinking that the servlet changes reflects?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic