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
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
"/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.
Joined: Feb 10, 2004
Thanks bahadar, that was good explanation......
i wanted to know 1.is there any difference between relative url and relative path ?
2.why is ("result.jsp") is a relative path not a relative url?
Joined: Jun 19, 2003
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: