Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Relative url ,Relative path

 
pallavi utukuri
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Kailas Lovlekar
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pallavi, what's HFS?
 
Bahadar Khan
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kailas,

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

Pallavi,

'/' 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.

MyWebApp/WebPages/A.jsp
MyWebApp/WebPages/B.jsp

and

MyWebApp/result.jsp

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>

But

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.


cheer
-Bahadar
 
pallavi utukuri
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bahadar Khan
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pallavi,

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:


cheers
-Bahadar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic