File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Relative url ,Relative path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Relative url ,Relative path" Watch "Relative url ,Relative path" New topic

Relative url ,Relative path

pallavi utukuri
Ranch Hand

Joined: Feb 10, 2004
Posts: 182
in HFS page 136 its given that relavite url's come in two flavours with and without "/"....but in page 204 its given that ("result.jsp") is a relative path as there is not initial forward slash "/" .....
i dont understand the difference between relative url and relative path

Thanks,<br />Pallavi
Kailas Lovlekar
Ranch Hand

Joined: Oct 25, 2004
Posts: 34
Pallavi, what's HFS?

SCJP/SCWCD/SCEA/OCA/Pega System Architect
Bahadar Khan
Ranch Hand

Joined: Jun 19, 2003
Posts: 81

HFS is referred to Head First Servlets and JSP book. A popular book with SCWCD audience.


'/' means the code base of your application. When you see something like this

/result.jsp, this means that result.jsp is located inside your web application directory. In this case we assume this is "MyWebApp"
Iniside assume there is <WebPages> directory. Now inside there there are two .jsp pages, say, A.jsp and B.jsp

Here is the scheme.




If you refer A.jsp from within B.jsp as "A.jsp", the container will look for A.jsp relative to the calling page. That is it will look in directory <WebPAges>


if you need to refer to the result.jsp from the same B.jsp page,
there are two ways,

"../result.jsp" that is, relative to current page

or secondly,

"/result.jsp" that is, relative to root of web application, in other words "MyWebApp". '/' represnts "MyWebApp".

Hope this might help. Let me know if you need further help on this.

pallavi utukuri
Ranch Hand

Joined: Feb 10, 2004
Posts: 182
Thanks bahadar, that was good explanation......

i wanted to know there any difference between relative url and relative path ?

2.why is ("result.jsp") is a relative path not a relative url?
Bahadar Khan
Ranch Hand

Joined: Jun 19, 2003
Posts: 81

I am not sure that there is any difference between relative path or relative URL. However, after some brain grinding there is a subtle difference and that is

: A relative path is a realistic fix pattren pointing to a resource
: A relative URL is however similar except that URL can be ficticious, meaning by it may contain name of some resource but that might be a logical naming. As an example look at <url-pattern> tag. This defines a logical mapping to a resource.

Though I am not very certain about my understanding of this. The purpose is to give some food of thought for other ranchers to come and discuss it. Anyways a brainy question :roll:

I agree. Here's the link:
subject: Relative url ,Relative path
Similar Threads
Servlet+AJAX -- I am getting request.status = 404 Error
clarifying path for Redirect & Dispatcher
response.sendRedirect issue
doubt error-page attribute of page directive
JSP and Path related Question