• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How does JSP engine understand need to translate JSP into Servlet and recompile?

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
This might look simple 4 u.
How does JSP engine understand need to translate JSP into Servlet and recompile?
The answer is obvious, JSP engine looks at timestamp of jsp and translated servlet class file. If jsp file is most recently modified, it is translated again.
That's fine. But let's take an example where index.jsp inlcludes header.jsp. The index.jsp is translated into servlet and servlet is compiled. But then I modify header.jsp without modifying index.jsp. Still JSP engine understands there is need to recompile servlet.
Can any one clarify whether code for included jsp is also put in translated servlet or only included JSP page's servlet's response is included in the including servlet?
In simple words, whether servlet of index.jsp will include code for header.jsp also? Or it will simply have code to include response from servlet created for header.jsp?
Pls clarify.
Thanks in advance.
Sandesh
 
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if the include directive is used the included file is actually copied into the servlet that is generated for the jsp page that includes it. changes in the included file are not updated in the main page until you change the main page
if jsp:include is used the included file is processed at runtime and so changes in the included file are always effective immediately.
if you want to know exactly how each is done do one of each and look in your tomcat/work directory to see what the generated code is!
 
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sandesh,
As I said in last post.
If you Use jsp:include then the output of included jsp is copied in your outputstream object(out)
where as if you use
<%@ include file=.... %>
then the actual code is copied in your jsp which is including other jsp.
so in your example servlet of index.jsp will include code of header.jsp
if you use <%@ include ......%>
else it will simply have code to include response from servlet created for header.jsp.
SO I guess ,if header.jsp is changed and Index.jsp is not,then there is no way for server to understand that Index.jps has to be recompiled so in this case the changes should not reflect in output of index.jsp.
But this is just my guesing ,plz verify,and do let me know if i m wrong
Hope I was't confusing
Cheers
Praful
 
There is no "i" in denial. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic