• 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

Difference in the behaviour of JSP and Servlet

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Shahnawaz Shakil
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you mean to say that as soon as we save the JSP file it is translated and compiled automatically?
Thanks for answering.
 
Ranch Hand
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Shahnawaz Shakil
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jesus, it was helpful
 
Jesus Angeles
Ranch Hand
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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'.
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic