Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Decoded URI

 
Maxim Katcharov
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using HttpServletRequest.getRequestURI(), because I need this simple form (from javadoc):

First line of HTTP request Returned Value
POST /some/path.html HTTP/1.1/some/path.html
GET http://foo.bar/a.html HTTP/1.0 /a.html
HEAD /xyz?a=b HTTP/1.1/xyz

Unfortunately, "The web container does not decode this String", which leaves me with things like /foo%20bar.html when I call it.

I need a clean way to decode the URI that is returned (or to convert the returned value of getRequestURL into the 'simple' form above).

Does anyone have any ideas?
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The java.net.URLDecoder and URLEncoder classes handle this.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Maxim Katcharov:
First line of HTTP request Returned Value
POST /some/path.html HTTP/1.1/some/path.html
GET http://foo.bar/a.html HTTP/1.0 /a.html
HEAD /xyz?a=b HTTP/1.1/xyz

Unfortunately, "The web container does not decode this String", which leaves me with things like /foo%20bar.html when I call it.


Means you are getting "/foo%20bar.html" instead of "/a.html"??
 
Maxim Katcharov
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That was a lot easier than I was finding it to be, thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic