Forums Register Login

Difference in the behaviour of JSP and Servlet

+Pie Number of slices to send: Send
Hi,
Perhaps its a simple question but i have this confusion. I am using Netbeans 5.5 IDE with bundled tomcat server. Why it happens that if i make some changes in JSP, i need not to build the project again. Simply clicking on the refresh button of the browser (IE) shows the changes. However if i make some changes in the servlet, i need to build the project again. Is it not strange because afterall even JSP are first translated to java class and consequently to servlet. Then why this difference in their behaviour?
+Pie Number of slices to send: Send
 

Originally posted by Shahnawaz Shakil:
Hi,
if i make some changes in JSP, i need not to build the project again. Simply clicking on the refresh button of the browser (IE) shows the changes.



no need to save ?
-------------------------------------------------------------------------
the reason is JSP is a precompiled page where the servlet is not
--------------------------------------------------------------------------

Hope This Helps
+Pie Number of slices to send: Send
So you mean to say that as soon as we save the JSP file it is translated and compiled automatically?
Thanks for answering.
+Pie Number of slices to send: Send
Servers process the JSP and convert into java classes (servlet) during 'runtime'. If your server detects a new version of a JSP is deployed, it processes it, and 'compiles' it as you described.

Servlets are deployed into servers in 'compiled already' format, like as a class file ending in '.class'.

The server wont compile a servlet for you. It expects a compiled one.

You cannot dump a .java (servlet in your case) file into the server and expect the server to compile it.
+Pie Number of slices to send: Send
Thanks Jesus, it was helpful
+Pie Number of slices to send: Send
 

Originally posted by Shahnawaz Shakil:
Thanks Jesus, it was helpful



Some IDE, I am not sure if your netbeans version does it, have an option for 'auto build'.

Anytime you save the java class (servlet in your case) while you are inside the IDE and have the 'auto build' turned on, some IDEs would automatically rebuild whatever needs to be rebuilt, and deploy the appropriate files into the server automatically (if server is up) - all happening automatically after you revise a class and click 'save'.
+Pie Number of slices to send: Send
Great Jesus you are correct!!!
Servers only expect compiled servlets and makes JSP's turn into java classes. So i believe we should always fresh deploy when we make changes to servlets rather than JSPs.

-vikas.
SCJP 1.4.
Once upon a time there were three bears. And they were visted by a golden haired tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 901 times.
Similar Threads
Automatic Compilation
JSP/ Servlet
Problem with Work folder
Need replacement book (Struts)
JSP reloading error
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 19, 2024 02:04:06.