• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getPathInfo() ?

 
Raj Paul
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
what is this HttpServletRequest.getPathInfo().
In API it has been said that it will return any extra path after servlet but before query string.
what would be the ideal condition for this.
any example ?
Thanks & Regards
Mike
 
raj sekar
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PathInfo: Part of the request path that is not
part of Context Path or Servlet Path
requestURI = contextPath + servletPath + PathInfo
Example : /helloApp/helloServlet/index.html
ContextPath: /helloApp
Servlet : /helloServlet
PathInfo : /index.html
Raj
 
Tybon Wu
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, one use for it is to specify parameters without using query strings.
For example, instead of the URL
somesite.com/servlet/someservlet?param1=66&param2=99
You can use
somesite.com/servlet/someservlet/66/99
It looks better and maybe more search engine friendly.
[ July 25, 2002: Message edited by: Tybon Wu ]
[ July 25, 2002: Message edited by: Tybon Wu ]
 
Raj Paul
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tybon,
where will you specify the parameter ? ( i mean to say 67/68) in the form tag ??
suppose i am calling one servlet in form tag
<form action="TestServlet"> </form>
where will you specify the extra path.
if we give action="TestServlet/68/69" will it work ? how the mapping would be done
Please give me a clear answer
Thanks & Regards
Mike
 
Tybon Wu
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes that should work. In TestServlet, you can call request.getPathInfo(), which will return "/68/69", which you can extract 68 and 69 as your parameter values.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic