Forums Register Login

Difference between JSP and Servlets

+Pie Number of slices to send: Send
Hello,
I want to know why we need not restart apache/tomcat server if we make a change in jsp file. Just refreshing a browser will reflect my changes. On the other hand if i make a change in servlet(java file) i need to restart tomcat/apache to reflect those changes.

Regards
Ashish
+Pie Number of slices to send: Send
Containers have separate class loader for JSPs and are designed to watch the dates of the files to reload them when they change.
This makes editing JSPs as easy as working with scripting languages like PHP, ASP, Perl, etc....
+Pie Number of slices to send: Send
Thanks for reply.
Does it mean that separate class loaders are used for servlets and jsps.
Container might be running inside one VM having default embedded class loader which is used to load servlet class files,but in case of JSP custom class loaders are used is it what you mean. Moreover it chooses files to recompile
based on timestamps.
PS: If you can throw some light on what it means by precompilation of jsps.

Regards
Ashish
+Pie Number of slices to send: Send
Not separate JVMs.
They all run under the same JVM but there are custom classloaders to make JSPs behave more like scripts.

If you can throw some light on what it means by precompilation of jsps.



As the name implies, it's possible to compile all the of the JSPs in an application ahead of time. There are ups and downs to doing this.
Doing so means that each page is already compiled before the first user hits it so the user doesn't experience the slight delay that it takes to compile the JSP to servlet code, compile the servlet to byte code, and load the servlet. When deployed this way, some containers allow you to shut off the checking mechanism (the one that checks the date stamp of each JSP before serving it up) which also speeds things up. From a security standpoint, an app with pre-compiled JSPs doesn't require a compiler. If there is no compiler on the production server, then it is harder for a hacker to get their own code running on that box.

The down side is that you loose the script like convenience of being able to upgrade an app on the fly by editing or replacing a simple JSP file (which is a text file).
[ June 04, 2008: Message edited by: Ben Souther ]
+Pie Number of slices to send: Send
Got it!!! Thanks
Ashish
Friends help you move. Good friends help you move bodies. This tiny ad will help:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2007 times.
Similar Threads
eclipse tomcat context reloading on each jsp save :(
Apache / mod_webapp / Tomcat caching
load servlet automatically when changed without restarting server
I need changes of xml file reflecting with out restart tomcat
Restarting Websphere v5.0 Test Environment
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 03:38:50.