You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by alex <al...@gmail.com> on 2011/02/21 05:25:58 UTC

related to bad url encoding?...

hi all,
I get 404 err, if I add %D0 to url, but I get just blank page if I add 
%zD0 . I'm supposed to get bad request in this case. how do I fix this 
problem?


thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: related to bad url encoding?...

Posted by Mark Thomas <ma...@apache.org>.
On 22/02/2011 21:36, alex wrote:
> Mark Thomas wrote:
>> On 22/02/2011 17:26, Caldarale, Charles R wrote:
>>>> From: alex [mailto:alex.alex.alex.9999@gmail.com] Subject: Re:
>>>> related to bad url encoding?...
>>>> shouldn't it be 404 error if tomcat can't map "this call"?
>>> Tomcat 7 has introduced revised handling for situations where there
>>> is no ROOT webapp; you might want to try that.  Regardless, you still
>>> can only use a custom error page on a mapping failure if you've got a
>>> default webapp (ROOT) and configure ROOT's WEB-INF/web.xml for it.
>>
>> It isn't going to help in this case. The URL is not valid so it is
>> correctly rejected by the connector with a 400 response. Since the URL
>> is invalid, it can't reliably be used to map it to a web application so
>> there is no opportunity to use an application generated/supplied error
>> page.
> 
> so, what do I do if I need to show error in this scenario and I run
> standalone tomcat?
> can I do it in custom filter/connector or the only solution to place
> tomcat behind apache?

A filter is too late in the chain, as is a valve. A custom connector
code seems like overkill for this. I would probably go with httpd myself.

There may be a way to get the request to be forwarded to the default
host where the default error handler could respond but I suspect that
approach could quickly get messy. One of the reasons for rejected the
requests in the connector was performance.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: related to bad url encoding?...

Posted by André Warnier <aw...@ice-sa.com>.
alex wrote:
...

> 
> so, what do I do if I need to show error in this scenario and I run 
> standalone tomcat?
...

It seems to me that by the 400 status code, the error is already shown, correctly.
Tomcat is doing the minimum, but it is doing it according to the RFC.

HTTP RFC 2616 says:

10.4 Client Error 4xx

The 4xx class of status code is intended for cases in which the client seems to have erred.
Except when responding to a HEAD request, the server SHOULD include an entity containing
an explanation of the error situation, and whether it is a temporary or permanent condition.
These status codes are applicable to any request method. User agents SHOULD display any 
included entity to the user.
...

(Notice "SHOULD", not "MUST").

10.4.1 400 Bad Request
The request could not be understood by the server due to malformed syntax.
The client SHOULD NOT repeat the request without modifications.

(This thus seems to be the appropriate status code. After all, the client /did/ send a 
malformed URL.)

(In any case, none of the other ones seems to fit.)

10.4.2 401 Unauthorized
10.4.3 402 Payment Required
10.4.4 403 Forbidden
10.4.5 404 Not Found
10.4.6 405 Method Not Allowed
10.4.7 406 Not Acceptable
10.4.8 407 Proxy Authentication Required
10.4.9 408 Request Timeout
10.4.10 409 Conflict
10.4.11 410 Gone
10.4.12 411 Length Required
10.4.13 412 Precondition Failed
10.4.14 413 Request Entity Too Large
10.4.15 414 Request-URI Too Long
10.4.16 415 Unsupported Media Type
10.4.17 416 Requested Range Not Satisfiable
10.4.18 417 Expectation Failed


Re: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: related to bad url encoding?...

Posted by alex <al...@gmail.com>.
Mark Thomas wrote:
> On 22/02/2011 17:26, Caldarale, Charles R wrote:
>>> From: alex [mailto:alex.alex.alex.9999@gmail.com] 
>>> Subject: Re: related to bad url encoding?...
>>> shouldn't it be 404 error if tomcat can't map "this call"?
>> Tomcat 7 has introduced revised handling for situations where there is no ROOT webapp; you might want to try that.  Regardless, you still can only use a custom error page on a mapping failure if you've got a default webapp (ROOT) and configure ROOT's WEB-INF/web.xml for it.
> 
> It isn't going to help in this case. The URL is not valid so it is
> correctly rejected by the connector with a 400 response. Since the URL
> is invalid, it can't reliably be used to map it to a web application so
> there is no opportunity to use an application generated/supplied error page.

so, what do I do if I need to show error in this scenario and I run 
standalone tomcat?
can I do it in custom filter/connector or the only solution to place 
tomcat behind apache?



> 
> Mark
> 
> PS The change in 7 just returns a 404 rather than a 400 for requests to
> / when there is no ROOT web application defined.
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: related to bad url encoding?...

Posted by Mark Thomas <ma...@apache.org>.
On 22/02/2011 17:26, Caldarale, Charles R wrote:
>> From: alex [mailto:alex.alex.alex.9999@gmail.com] 
>> Subject: Re: related to bad url encoding?...
> 
>> shouldn't it be 404 error if tomcat can't map "this call"?
> 
> Tomcat 7 has introduced revised handling for situations where there is no ROOT webapp; you might want to try that.  Regardless, you still can only use a custom error page on a mapping failure if you've got a default webapp (ROOT) and configure ROOT's WEB-INF/web.xml for it.

It isn't going to help in this case. The URL is not valid so it is
correctly rejected by the connector with a 400 response. Since the URL
is invalid, it can't reliably be used to map it to a web application so
there is no opportunity to use an application generated/supplied error page.

Mark

PS The change in 7 just returns a 404 rather than a 400 for requests to
/ when there is no ROOT web application defined.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: related to bad url encoding?...

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: alex [mailto:alex.alex.alex.9999@gmail.com] 
> Subject: Re: related to bad url encoding?...

> shouldn't it be 404 error if tomcat can't map "this call"?

Tomcat 7 has introduced revised handling for situations where there is no ROOT webapp; you might want to try that.  Regardless, you still can only use a custom error page on a mapping failure if you've got a default webapp (ROOT) and configure ROOT's WEB-INF/web.xml for it.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: related to bad url encoding?...

Posted by alex <al...@gmail.com>.
André Warnier wrote:
> alex wrote:
>> Mark Thomas wrote:
>>> On 22/02/2011 13:27, alex wrote:
>>>> alex wrote:
>>>>> Mark Thomas wrote:
>>>>>> On 21/02/2011 04:25, alex wrote:
>>>>>>> hi all,
>>>>>>> I get 404 err, if I add %D0 to url, but I get just blank page if 
>>>>>>> I add
>>>>>>> %zD0 . I'm supposed to get bad request in this case. how do I fix 
>>>>>>> this
>>>>>>> problem?
>>>>>> Check the response headers.
>>>>>>
>>>>>> If you don't see a 400 response, exactly which Tomcat version are you
>>>>>> using?
>>>>>>
>>>>>> Mark
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>>>
>>>>> I used 6.0.24 .
>>>>> http://localhost:8080/examples/servlets/%D0 returns 404
>>>>> http://localhost:8080/examples/servlets/%zD0 returns blank page
>>>>>
>>>>>
>>>> Can anyone tell me if it's a bug or a problem on my side?
>>>> thanks.
>>>
>>> Again, look at the response *headers*.
>>>
>>> Mark
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>
>> Mark,
>> it does return 400 code, but in my app I set:
>> ...
>>    <error-page>
>>     <error-code>400</error-code>
>>     <location>/WEB-INF/error.jsp</location>
>>   </error-page>
>>    <error-page>
>>     <error-code>404</error-code>
>>     <location>/WEB-INF/error.jsp</location>
>>   </error-page>
>> .....
>>
>> and tomcat doesn't show it. this custom err page is shown for 404 
>> code, but not for 400...
>> Can you give me a hint why?
>> thanks again.
>>
> probably because :
> because of the bad URL, Tomcat never even "maps" this call to your 
> application, 

shouldn't it be 404 error if tomcat can't map "this call"?


>so it sends its own 400 error page (as Konstantin already > explained, I believe).




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: related to bad url encoding?...

Posted by André Warnier <aw...@ice-sa.com>.
alex wrote:
> Mark Thomas wrote:
>> On 22/02/2011 13:27, alex wrote:
>>> alex wrote:
>>>> Mark Thomas wrote:
>>>>> On 21/02/2011 04:25, alex wrote:
>>>>>> hi all,
>>>>>> I get 404 err, if I add %D0 to url, but I get just blank page if I 
>>>>>> add
>>>>>> %zD0 . I'm supposed to get bad request in this case. how do I fix 
>>>>>> this
>>>>>> problem?
>>>>> Check the response headers.
>>>>>
>>>>> If you don't see a 400 response, exactly which Tomcat version are you
>>>>> using?
>>>>>
>>>>> Mark
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>>
>>>> I used 6.0.24 .
>>>> http://localhost:8080/examples/servlets/%D0 returns 404
>>>> http://localhost:8080/examples/servlets/%zD0 returns blank page
>>>>
>>>>
>>> Can anyone tell me if it's a bug or a problem on my side?
>>> thanks.
>>
>> Again, look at the response *headers*.
>>
>> Mark
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
> 
> Mark,
> it does return 400 code, but in my app I set:
> ...
>    <error-page>
>     <error-code>400</error-code>
>     <location>/WEB-INF/error.jsp</location>
>   </error-page>
>    <error-page>
>     <error-code>404</error-code>
>     <location>/WEB-INF/error.jsp</location>
>   </error-page>
> .....
> 
> and tomcat doesn't show it. this custom err page is shown for 404 code, 
> but not for 400...
> Can you give me a hint why?
> thanks again.
> 
probably because :
because of the bad URL, Tomcat never even "maps" this call to your application, so it 
sends its own 400 error page (as Konstantin already explained, I believe).


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: related to bad url encoding?...

Posted by alex <al...@gmail.com>.
Mark Thomas wrote:
> On 22/02/2011 13:27, alex wrote:
>> alex wrote:
>>> Mark Thomas wrote:
>>>> On 21/02/2011 04:25, alex wrote:
>>>>> hi all,
>>>>> I get 404 err, if I add %D0 to url, but I get just blank page if I add
>>>>> %zD0 . I'm supposed to get bad request in this case. how do I fix this
>>>>> problem?
>>>> Check the response headers.
>>>>
>>>> If you don't see a 400 response, exactly which Tomcat version are you
>>>> using?
>>>>
>>>> Mark
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>
>>> I used 6.0.24 .
>>> http://localhost:8080/examples/servlets/%D0 returns 404
>>> http://localhost:8080/examples/servlets/%zD0 returns blank page
>>>
>>>
>> Can anyone tell me if it's a bug or a problem on my side?
>> thanks.
> 
> Again, look at the response *headers*.
> 
> Mark
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 

Mark,
it does return 400 code, but in my app I set:
...
    <error-page>
     <error-code>400</error-code>
     <location>/WEB-INF/error.jsp</location>
   </error-page>
    <error-page>
     <error-code>404</error-code>
     <location>/WEB-INF/error.jsp</location>
   </error-page>
.....

and tomcat doesn't show it. this custom err page is shown for 404 code, 
but not for 400...
Can you give me a hint why?
thanks again.








---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: related to bad url encoding?...

Posted by Mark Thomas <ma...@apache.org>.
On 22/02/2011 13:27, alex wrote:
> alex wrote:
>> Mark Thomas wrote:
>>> On 21/02/2011 04:25, alex wrote:
>>>> hi all,
>>>> I get 404 err, if I add %D0 to url, but I get just blank page if I add
>>>> %zD0 . I'm supposed to get bad request in this case. how do I fix this
>>>> problem?
>>>
>>> Check the response headers.
>>>
>>> If you don't see a 400 response, exactly which Tomcat version are you
>>> using?
>>>
>>> Mark
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>
>> I used 6.0.24 .
>> http://localhost:8080/examples/servlets/%D0 returns 404
>> http://localhost:8080/examples/servlets/%zD0 returns blank page
>>
>>
> Can anyone tell me if it's a bug or a problem on my side?
> thanks.

Again, look at the response *headers*.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: related to bad url encoding?...

Posted by alex <al...@gmail.com>.
alex wrote:
> Mark Thomas wrote:
>> On 21/02/2011 04:25, alex wrote:
>>> hi all,
>>> I get 404 err, if I add %D0 to url, but I get just blank page if I add
>>> %zD0 . I'm supposed to get bad request in this case. how do I fix this
>>> problem?
>>
>> Check the response headers.
>>
>> If you don't see a 400 response, exactly which Tomcat version are you 
>> using?
>>
>> Mark
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
> 
> I used 6.0.24 .
> http://localhost:8080/examples/servlets/%D0 returns 404
> http://localhost:8080/examples/servlets/%zD0 returns blank page
> 
> 
Can anyone tell me if it's a bug or a problem on my side?
thanks.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: related to bad url encoding?...

Posted by alex <al...@gmail.com>.
Mark Thomas wrote:
> On 21/02/2011 04:25, alex wrote:
>> hi all,
>> I get 404 err, if I add %D0 to url, but I get just blank page if I add
>> %zD0 . I'm supposed to get bad request in this case. how do I fix this
>> problem?
> 
> Check the response headers.
> 
> If you don't see a 400 response, exactly which Tomcat version are you using?
> 
> Mark
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 

I used 6.0.24 .
http://localhost:8080/examples/servlets/%D0 returns 404
http://localhost:8080/examples/servlets/%zD0 returns blank page



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: related to bad url encoding?...

Posted by Mark Thomas <ma...@apache.org>.
On 21/02/2011 04:25, alex wrote:
> hi all,
> I get 404 err, if I add %D0 to url, but I get just blank page if I add
> %zD0 . I'm supposed to get bad request in this case. how do I fix this
> problem?

Check the response headers.

If you don't see a 400 response, exactly which Tomcat version are you using?

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org