It's not a secret anymore!
The moose likes Tomcat and the fly likes URL encoding gives 404 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "URL encoding gives 404" Watch "URL encoding gives 404" New topic

URL encoding gives 404

Bill Goldsworthy

Joined: Dec 21, 2004
Posts: 27
I'm running Tomcat 5 on JDK 1.5

I'm getting 404 errors for requests when the URL is encoded which doesn't make sense to me.


/mypage.htm?page=A works

/mypage.htm%3fpage=A 404

Shouldn't this be handled automatically by tomcat? I've read the connector configuration docs but haven't been able to resolve this. I added URIEncoding="UTF-8" to my connectors but I don't believe this is even a UTF-8 encoding but ISO-Latin.

I tried URIEncoding="ISO-Latin1" (ISOLatin, ISOLatin1 etc.) to no avail.

Any ideas?


Increasingly, people seem to misinterpret complexity as sophistication, which is baffling - the incomprehensible should cause suspicion rather than admiration. Possibly this trend results from a mistaken belief that using a somewhat mysterious device confers an aura of power on the user. Niklaus Wirth
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

It makes sense to me. Those two URLs aren't equivalent; the first one refers to the name "mypage.htm" and has a parameter list "page=A" whereas the second one refers to the strange name "mypage.htm%3fpage=A" and doesn't have a parameter list.

Looks like whoever produced the second one wasn't quite clear on how URL-encoding should be used. Only the value parts of parameters in the parameter list need to be URL-encoded.
Bill Goldsworthy

Joined: Dec 21, 2004
Posts: 27
"Only the value parts of parameters in the parameter list need to be URL-encoded."

Excellent! We're trying to track down where the request is coming from now that I understand that it's the URL that's bad not because of some inability for Tomcat to decode it.

Much appreciated!
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63852

Yes, the whole reason for encoding is so that special characters like the ? (and = and &) can be used to format the URL.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: URL encoding gives 404
It's not a secret anymore!