You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by George Sexton <ge...@mhsoftware.com> on 2011/12/31 20:53:17 UTC

Servlet Mapping w/ Error Page

I have a servlet mapping for a page named

/403.html

I can invoke that URL and get a page as expected.

In my deployment descriptor, I have an error mapping:

<error-page>
<error-code>403</error-code>
<location>/403.html</location>
</error-page>

in my code I have

if (someCondition) {
     res.sendError(HttpServletResponse.SC_FORBIDDEN);
     return;
}

When this code is hit, my custom page is not displayed. I get a blank 
page. No error is thrown by tomcat.

If I change the error-page entry to reference a static HTML page, the 
page is displayed as expected.


This looks like  a bug to me, but I wanted to run it past tomcat-user 
and see what other people think.

-- 
George Sexton
MH Software, Inc.
303 438-9585
http://www.mhsoftware.com/


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


Re: Servlet Mapping w/ Error Page

Posted by "Terence M. Bandoian" <te...@tmbsw.com>.
  On 1:59 PM, George Sexton wrote:
>
>
> On 12/31/11 2:04 PM, Konstantin Kolinko wrote:
>> 2011/12/31 George Sexton<ge...@mhsoftware.com>:
>>> I have a servlet mapping for a page named
>>>
>>> /403.html
>>>
>>> I can invoke that URL and get a page as expected.
>>>
>>> In my deployment descriptor, I have an error mapping:
>>>
>>> <error-page>
>>> <error-code>403</error-code>
>>> <location>/403.html</location>
>>> </error-page>
>>>
>>> in my code I have
>>>
>>> if (someCondition) {
>>>     res.sendError(HttpServletResponse.SC_FORBIDDEN);
>>>     return;
>>> }
>>>
>>> When this code is hit, my custom page is not displayed. I get a 
>>> blank page.
>>> No error is thrown by tomcat.
>>>
>>> If I change the error-page entry to reference a static HTML page, 
>>> the page
>>> is displayed as expected.
>>>
>>>
>>> This looks like  a bug to me, but I wanted to run it past 
>>> tomcat-user and
>>> see what other people think.
>>>
>> 1. Tomcat version=?
> Sorry, I had the best of intentions here. I dl'd the 6.0 for testing.
>
>
> 6.0.35
>
>
>> Overall it looks like a bug. But if you submit it I expect you to
>> provide a simple sample webapp that reproduces it on 7.0.23.
>
> I could do that.

Hi, George-

One thing to look out for is that <location> is "relative to the root of 
the web application".  To me, this means that the error page must exist 
in every context in which it is declared.

-Terence Bandoian


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


Re: Servlet Mapping w/ Error Page

Posted by George Sexton <ge...@mhsoftware.com>.

On 12/31/11 2:04 PM, Konstantin Kolinko wrote:
> 2011/12/31 George Sexton<ge...@mhsoftware.com>:
>> I have a servlet mapping for a page named
>>
>> /403.html
>>
>> I can invoke that URL and get a page as expected.
>>
>> In my deployment descriptor, I have an error mapping:
>>
>> <error-page>
>> <error-code>403</error-code>
>> <location>/403.html</location>
>> </error-page>
>>
>> in my code I have
>>
>> if (someCondition) {
>>     res.sendError(HttpServletResponse.SC_FORBIDDEN);
>>     return;
>> }
>>
>> When this code is hit, my custom page is not displayed. I get a blank page.
>> No error is thrown by tomcat.
>>
>> If I change the error-page entry to reference a static HTML page, the page
>> is displayed as expected.
>>
>>
>> This looks like  a bug to me, but I wanted to run it past tomcat-user and
>> see what other people think.
>>
> 1. Tomcat version=?
Sorry, I had the best of intentions here. I dl'd the 6.0 for testing.


6.0.35


> Overall it looks like a bug. But if you submit it I expect you to
> provide a simple sample webapp that reproduces it on 7.0.23.

I could do that.

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

-- 
George Sexton
MH Software, Inc.
303 438-9585
http://www.mhsoftware.com/


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


Re: Servlet Mapping w/ Error Page

Posted by George Sexton <ge...@mhsoftware.com>.

On 12/31/11 2:04 PM, Konstantin Kolinko wrote:
> 2011/12/31 George Sexton<ge...@mhsoftware.com>:
>> I have a servlet mapping for a page named
>>
>> /403.html
>>
>> I can invoke that URL and get a page as expected.
>>
>> In my deployment descriptor, I have an error mapping:
>>
>> <error-page>
>> <error-code>403</error-code>
>> <location>/403.html</location>
>> </error-page>
>>
>> in my code I have
>>
>> if (someCondition) {
>>     res.sendError(HttpServletResponse.SC_FORBIDDEN);
>>     return;
>> }
>>
>> When this code is hit, my custom page is not displayed. I get a blank page.
>> No error is thrown by tomcat.

I looked at this a little more. It looks like the response may have been 
committed before calling HttpServletResponse.sendError(). Once I 
re-structured the code to not commit the response, it started working.

>>
>> If I change the error-page entry to reference a static HTML page, the page
>> is displayed as expected.
>>
>>
>> This looks like  a bug to me, but I wanted to run it past tomcat-user and
>> see what other people think.
>>
> 1. Tomcat version=?
>
> Overall it looks like a bug. But if you submit it I expect you to
> provide a simple sample webapp that reproduces it on 7.0.23.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>

-- 
George Sexton
MH Software, Inc.
303 438-9585
http://www.mhsoftware.com/


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


Re: Servlet Mapping w/ Error Page

Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/12/31 George Sexton <ge...@mhsoftware.com>:
> I have a servlet mapping for a page named
>
> /403.html
>
> I can invoke that URL and get a page as expected.
>
> In my deployment descriptor, I have an error mapping:
>
> <error-page>
> <error-code>403</error-code>
> <location>/403.html</location>
> </error-page>
>
> in my code I have
>
> if (someCondition) {
>    res.sendError(HttpServletResponse.SC_FORBIDDEN);
>    return;
> }
>
> When this code is hit, my custom page is not displayed. I get a blank page.
> No error is thrown by tomcat.
>
> If I change the error-page entry to reference a static HTML page, the page
> is displayed as expected.
>
>
> This looks like  a bug to me, but I wanted to run it past tomcat-user and
> see what other people think.
>

1. Tomcat version=?

Overall it looks like a bug. But if you submit it I expect you to
provide a simple sample webapp that reproduces it on 7.0.23.

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