Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Is This Stupid?  RSS feed

 
Garrett Smith
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I couldn't find a better way, but it looks so cumbersome.
Compare this alternative.

The second won't work when using a request dispatcher, because getServletPath is not what the user requested.
Couldn't find a better way to do that simple task and it bothered me.
 
Garrett Smith
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
^^^
 
Garrett Smith
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
request.getRequestURI() won't work with a dispatcher because the "real" requested resource is not what the user requested.
request.getRequestURL() does return exactly what the user requested, not the server mapping to the resource.
(should be ==, or startsWith(uri) to be more concise.)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!