aspose file tools*
The moose likes JSP and the fly likes How does JSP engine understand need to translate JSP into Servlet and recompile? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How does JSP engine understand need to translate JSP into Servlet and recompile?" Watch "How does JSP engine understand need to translate JSP into Servlet and recompile?" New topic
Author

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

Sandesh Tathare
Ranch Hand

Joined: Jun 22, 2003
Posts: 82
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


Regards,<br />Sandesh<br />(SCJCP, SCWCD, SCBCD - 99%, OCP-1)<br /> <br />Either find a way or create one.
Tim Baker
Ranch Hand

Joined: Oct 04, 2003
Posts: 541
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!


Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 639
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


All desirable things in life are either illegal, banned, expensive or married to someone else !!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How does JSP engine understand need to translate JSP into Servlet and recompile?