• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

relative path and absolute path

 
agrah upadhyay
Ranch Hand
Posts: 579
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please anyone help me regarding when and where to use relative path and when absolute path.There has been so much confusion regarding it.I think that I am not clear with relative path and absolute path even.Please anbody clear the difference and tell me where to use what like in forward(), in include(),in sendRedirect() and other places?
 
lalit upadheyay
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we use absolute path to access resources on a different web application in different web server( so sessions and other working environment like request attributes will not be available there).

we use relative path to access resources for applications hosted on same serve. further we can specify context relative or page relative path. A context relative path belongs to another application on same server(foreign context) and page relative path refers to path which current requested page belongs to(same context).
 
agrah upadhyay
Ranch Hand
Posts: 579
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Lalit Hope it shall help.
 
Lux Gupta
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,
Something i want to add,
May be it is useful

The getRequestDispatcher(String path) method of javax.servlet.ServletRequest interface accepts parameter the path to the resource to be included or forwarded to, which can be relative to the request of the calling servlet. If the path begins with a "/" it is interpreted as relative to the current context root.

The getRequestDispatcher(String path) method of javax.servlet.ServletContext interface cannot accepts relative paths. All path must sart with a "/" and are interpreted as relative to curent context root.
 
Patrick Williams
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Short answer (as I understand it so please correct me if I am wrong)

redirect - Servlet handles navigating the client to a different web resource (URL, servlet, etc)

include - same as redirect, but the client goes back to the servlet that issued the "include" call

sendRedirect - the servlet instructs the client (browser) to go to a given URL and the client/browser will accept the instruction and process the rediection outside of the servlet.

Hope this helps.
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

client


request will be a more appropriate word.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic