aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Include Standard Action and Directive Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Include Standard Action and Directive" Watch "Include Standard Action and Directive" New topic
Author

Include Standard Action and Directive

Hasnain Javed Khan
Ranch Hand

Joined: Nov 23, 2007
Posts: 73
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

Joined: Nov 23, 2007
Posts: 73
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

Joined: Jul 14, 2009
Posts: 76
Hi All


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


Thanks


Rachna Jain
SCWCD 1.5
Poonam Kohli
Ranch Hand

Joined: Jun 10, 2009
Posts: 53
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

Joined: Nov 23, 2007
Posts: 73
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.
 
wood burning stoves
 
subject: Include Standard Action and Directive