Reputation: 33
I need help on the issue where we are appending special character like % with URL. Suppose my application URL is "http://www.google.com/".
we have our custom error page which will come when server will not find URL address. scenario 1: hitting "http://www.google.com/sdfkdjkfj :---redirecting on custom error page which is correct.
Scenario 2: hitting "http://www.google.com/% :--Instead of redirecting on my own custom page it is showing message "this page is not working HTTP ERROR 400".
we are using below code in web.xml to handle the page not found exception.
<error-page>
<error-code>404</error-code>
<location>/ErrorPage.jsp</location>
.
Please help on scenario 2 .
Upvotes: 0
Views: 527
Reputation: 718826
If you want to include a % character in a URL, it needs to be percent-encoded; e.g. http://www.google.com/%25
. (That URL still may not be recognized, but at it is syntactically well-formed.)
Upvotes: 1
Reputation: 333
Error code 400 means "Bad request", the server cannot understand this request. Generally you should avoid passing special character "%" in your URL like in your example. However if you want to pass this character and preserve its meaning, try to encode it: https://www.w3schools.com/tags/ref_urlencode.asp. When you try http://www.google.com/%25 - you will have 404 error.
Upvotes: 0