Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javax. servlet. include. path_info not set.

 
Ke Cheng
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The serlvet spec said:

Except for servlets obtained by using the getNamedDispatcher
method, a servlet that has been invoked by another servlet
using the include method ofRequestDispatcher has access to
the path by which it was invoked.The following request attri-
butes must be set:

javax.servlet.include.request_uri
javax.servlet.include.context_path
javax.servlet.include.servlet_path
javax.servlet.include.path_info
javax.servlet.include.query_string

However, when I tried, I found "javax.servlet.include.path_info"
and "javax.servlet.include.query_string" never set, even though
the query URI contains path info and query string.

On the other hand, when forwarding, the "javax.servlet.forward.
path_info" and "javax.servlet.forward.query_string" are set when
the URI contains path info and query string.

I don't know what's wrong here. And It's the same behavior under
Tomcat 5.5 and AppServer9.

My test code is as following, and the mapping is:
Forwarder -> /Forwarder/*
Includer -> /Includer/*
Target -> /Target

 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

When the request is forwarded :

The attributes are set to the value of calling URI. In your case the calling URI is something like /appname/Forwarder/pathinfo?param=value. So the Path info and the query parametered will be shown from this URI. The Path Info and the request parameter will be showon as Youre URI is matche by the path of the pattern /somepath/* pattern . It is not exact matching pattern pattern.

When the request is included :

The attributes are set to the value of target URI. Your target URI is matching with exact match, so there is no question of the path info. It will always null. The Query String can appears if you set the query string parameter to your target URI, that is /Target.

Hope this help

Thanks
 
Ke Cheng
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Narendra Dhande:
I think I understand what's the difference now. Many thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic