• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

include directive

 
Srinivasa Gundapu
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody explain what exactly will be includeed with include directive in the following code..
<%@ include file="sampleA.jsp" %>
Will this include the processed output of sampleA.jsp or the text present(code) inside the sampleA.jsp
If I am not wrong, it should display the the contents present in the sampleA.jsp. Because the spec says
"//
An include directive regards a resource like a JSP page as a static object; i.e.
the bytes in the JSP page are included.
//"..
Thanks,
Srinivas
 
Kevin Mukhar
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Srinivasa Gundapu:
Can anybody explain what exactly will be includeed with include directive in the following code..
<%@ include file="sampleA.jsp" %>
Will this include the processed output of sampleA.jsp or the text present(code) inside the sampleA.jsp
If I am not wrong, it should display the the contents present in the sampleA.jsp. Because the spec says
"//
An include directive regards a resource like a JSP page as a static object; i.e.
the bytes in the JSP page are included.
//"..

The spec is correct because at the time the page is translated, the include directive causes the contents to be included in the first page. So, if you look at the translated .java file, the contents of sampleA.jsp will be directly included in the .java file. That is, the result of the include directive is that the contents of sampleA.jsp become a part of the translated file.
When you say, "it should display the contents" are you asking if the unprocessed contents are visible to the client browser? If so, then that is incorrect.
The included file becomes a part of the translated JSP. But then the translated JSP is compiled and what is sent to the client's browser is the result of processing the page which includes the result of processing the code from sampleA.jsp that was included in the page.
So, on the server side, the contents of the sampleA.jsp are inserted into the translated page. On the client side, the client sees the result of the processed page.
 
Srinivasa Gundapu
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks kevin. Great explanation. Thats what I am looking for. I am seeing the processed output of the second jsp in the first jsp presentation. I thought the otherway, means instead of showing the processed output, it would show the code in the jsp.
Thanks. I got you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic