aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes JSP and Path related Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "JSP and Path related Question" Watch "JSP and Path related Question" New topic
Author

JSP and Path related Question

M Jairam
Greenhorn

Joined: Nov 04, 2005
Posts: 22
This question is from HFSJ page 424.
Question: The following code fragment appears in a JSP page:
<jsp:include page="/jspf/header.html" />
The JSP page is part of a web application with the context root myapp.
Given that the application's top level directory is myapp, what is the path to the header.html file?

A. /header.html
B. /jspf/header.html
C. /myapp/jspf/header.html ....according to the book - correct answer.
D. /includes/jspf/header.html

What I don't understand is the question itself. When it says "what is the path ...", my question is related to what? the server root? or as it would be identified in <location> as defined in web.xml (then the correct answer would be B not C).
Thus, what is the context of the question? or am I missing something that is obvious?

Thanks.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1506
I think the question is just asking what is the path as in the "file path"


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
If a back slash is present it is considered relative to the current context root. Here the current context root is "myapp"

The server interprets a relative URL relative to the current directory. Here the current directory is "/jspf/header.jsp"

<jsp:include page="/jspf/header.jsp" />

And final answer is:
<%-- Includes: /myapp/jspf/header.jsp --%>
[ December 02, 2005: Message edited by: Vishnu Prakash ]

Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
If the relative URL starts with /, the path is relative to the JSP application's context, If the relative URL starts with a directory or file name, the path is relative to the JSP page.


MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: JSP and Path related Question
 
Similar Threads
mock question
jsp:include -> page attribute.
Not able to deploy web service war file with multilevel root context on tomcat6
First Jsp - HTTP 404/Not Found
valid implicit variables in a JSP