Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Include Standard Action and Directive

 
Hasnain Javed Khan
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I'm confused about the relative path that is given to the file attribute of include directive and page attribute of include standard action.I have quoted the explanation from the JSP 2 spec

The page attribute of both the jsp:include and the jsp:forward actions are
interpreted relative to the current JSP page, while the file attribute in an include
directive is interpreted relative to the current JSP file. See below for some
examples of combinations of this.

• A.jsp says <%@ include file=”dir/B.jsp”%> and dir/B.jsp says <%@ include
file=”C.jsp”%>. In this case the relative specification C.jsp resolves to dir/C.jsp.
• A.jsp says <jsp:include page=”dir/B.jsp”/> and dir/B.jsp says <jsp:include
page=”C.jsp” />. In this case the relative specification C.jsp resolves to dir/
C.jsp.
• A.jsp says <jsp:include page=”dir/B.jsp”/> and dir/B.jsp says <%@ include
file=”C.jsp” %>. In this case the relative specification C.jsp resolves to dir/C.jsp.
• A.jsp says <%@ include file=”dir/B.jsp”%> and dir/B.jsp says <jsp:include
page=”C.jsp”/>. In this case the relative specification C.jsp resolves to C.jsp.


The last example is confusing me . Can some one explain/clarify the current JSP PAGE in case of include standard action and the Current JSP FILE in case of the include standard action ? in the above given examples, is A.jsp the Current JSP PAGE/FILE in case of the include standard action/directive or B.jsp is the Current JSP PAGE/FILE in case of the include standard action/directive ?

Thanks in advance .
Kind Regards.
Hasnain Javed.

 
Hasnain Javed Khan
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hasnain Javed Khan wrote:
The last example is confusing me . Can some one explain/clarify the current JSP PAGE in case of include standard action and the Current JSP FILE in case of the include standard action ?

Sorry my bad. The Current JSP PAGE in case of include standard action and the Current JSP FILE in case of the include standard directive.

Kind Regards.
Hasnain Javed
 
rachna jain
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All


Can someone please clarify this doubt.I have great confusion and my exam is day after tommorrow.


Thanks
 
Poonam Kohli
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to see the java file created by Tomcat (I am assuming you are using tomcat).

This is what it generates in case of 4th example



This clearly looks for C.jsp under current folder.
 
Hasnain Javed Khan
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
Sorry for replying late. I wrote some JSPs and followed the example given below and ran them in Tomcat 6.18. The JSPs display their location on the file system.

Hasnain Javed Khan wrote:
• A.jsp says <%@ include file=”dir/B.jsp”%> and dir/B.jsp says <jsp:include
page=”C.jsp”/>. In this case the relative specification C.jsp resolves to C.jsp.


When A.jsp was accessed it printed out the following locations.

C.jsp
dir/B.jsp
A.jsp

but when B.jsp was accessed, it printed out the following lines.

dir/C.jsp
dir/B/.jsp

in the above given examples, is A.jsp the Current JSP PAGE/FILE in case of the include standard action/directive or B.jsp is the Current JSP PAGE/FILE in case of the include standard action/directive ?


All the includes (standard or directive) are relative to the JSP that is being accessed/requested/in question. Hope the assumption is correct. kindly correct me if I'm wrong.

Kind Regards.
Hasnain Javed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic