| Author |
JSP turning into Servlet
|
Charith Fernando
Ranch Hand
Joined: Sep 12, 2005
Posts: 67
|
|
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..
|
Charith I Fernando<br />SCJP5, SCWCD, SCBCD, BSc(Hons) IS<br />+94 773 263 222 (mobile)
|
 |
Bryan Basham
author
Ranch Hand
Joined: Apr 30, 2001
Posts: 199
|
|
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
Joined: Sep 12, 2005
Posts: 67
|
|
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..
|
 |
Aneesh Kumar
Greenhorn
Joined: Feb 26, 2004
Posts: 13
|
|
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
Joined: Feb 26, 2004
Posts: 13
|
|
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
Ranch Hand
Joined: Apr 30, 2001
Posts: 199
|
|
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
Joined: Sep 12, 2005
Posts: 67
|
|
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?
|
 |
 |
|
|
subject: JSP turning into Servlet
|
|
|