You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Ryan Hoegg <rh...@isisnetworks.net> on 2002/11/04 19:33:41 UTC

Possible bug in RequestDispatcher?

Hi,

Before I post a bug report, I wanted to run a peculiar situation by the 
experts.

I am creating some filters that verify that certain variables are in the 
session before allowing access to any page in my site.  There are 
currently two of them, and each forward the request to a form if a 
particular session variable is not set and if this is not the form 
submission.  They are using ((HttpServletRequest) 
request).getRequestDispatcher("/path/to/form1.html").forward(request, 
response) to accomplish this.

Something is broken, and if it's in my code I am missing it.  I have 
these filters mapped to /* and here is the peculiar behavior:
1. If I point my browser at "/", I get the desired HTML page.
2. If I point at a servlet I have mapped, I get what looks like an HTML 
template page.
3. If I point at a static HTML file I have in the "/" I get a good chunk 
of the beginning of the HTML page and that's it.

My web.xml is simpler than simple, I described it above except for the 
single servlet mapping. ("/Display")

I appreciate any insights you can provide!
--
Ryan Hoegg
ISIS Networks
http://www.isisnetworks.net


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Possible bug in RequestDispatcher?

Posted by Ryan Hoegg <rh...@isisnetworks.net>.
I looked into this a little further.  I think the resource the URL 
points to has a Content-Length of 234 bytes.  The Filter uses 
RequestDispatcher.forward() to return a document that is longer, and 
that document is getting truncated at about 234 bytes.

Could TC be setting the Content-Length header based on the originally 
requested document but returning the data from the forwarded one?

--
Ryan Hoegg
ISIS Networks
http://www.isisnetworks.net

Ryan Hoegg wrote:

> OK, that clarifies things a little bit.  If the problem isn't with 
> RequestDispatcher, I am even more puzzled.  I have narrowed the 
> problem down to a particular use case:
>
> I have a single filter that calls 
> getFilterContext().getServletContext().getRequestDispatcher("/WEB-INF/templates/form.html").forward(request, 
> response) in the absence of a particular session variable on the request.
>
> This filter is mapped to /* and I have a single servlet mapped to 
> /Display
>
> Pointing my browser at /<webapp>/Display : things work as expected.
> Pointing my browser at /<webapp>/ : things work as expected
> Pointing my browser at /<webapp>/staticfile.html : problem.
>
> View Source in my browser shows this:
> -----------------
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> <html>
>  <head>
>    <title></title>
>  </head>
>  <body>
>    <form action="j_security_check" method="POST">
>      <p>U
> ----------------------
>
> That is the beginning of the html file I am trying to forward() to.
>
> It seems like my HttpServletResponse's OutputStream is getting closed 
> prematurely in the exact same place in my forwarded file.
>
> So what could it be?!
>
> -- 
> Ryan Hoegg
> ISIS Networks
> http://www.isisnetworks.net
>
> Craig R. McClanahan wrote:
>
>> In Servlet 2.3 (i.e. Tomcat 4.x), filters are *not* invoked on request
>> dispatcher calls -- only on the original request.  In Servlet 2.4 (i.e.
>> Tomcat 5.x) you can optionally configure which filters should be used on
>> forwards, includes, or both, with suitable settings in web.xml.
>>
>> Craig
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Possible bug in RequestDispatcher?

Posted by Ryan Hoegg <rh...@isisnetworks.net>.
OK, that clarifies things a little bit.  If the problem isn't with 
RequestDispatcher, I am even more puzzled.  I have narrowed the problem 
down to a particular use case:

I have a single filter that calls 
getFilterContext().getServletContext().getRequestDispatcher("/WEB-INF/templates/form.html").forward(request, 
response) in the absence of a particular session variable on the request.

This filter is mapped to /* and I have a single servlet mapped to /Display

Pointing my browser at /<webapp>/Display : things work as expected.
Pointing my browser at /<webapp>/ : things work as expected
Pointing my browser at /<webapp>/staticfile.html : problem.

View Source in my browser shows this:
-----------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
  <head>
    <title></title>
  </head>
  <body>
    <form action="j_security_check" method="POST">
      <p>U
----------------------

That is the beginning of the html file I am trying to forward() to.

It seems like my HttpServletResponse's OutputStream is getting closed 
prematurely in the exact same place in my forwarded file.

So what could it be?!

--
Ryan Hoegg
ISIS Networks
http://www.isisnetworks.net

Craig R. McClanahan wrote:

>In Servlet 2.3 (i.e. Tomcat 4.x), filters are *not* invoked on request
>dispatcher calls -- only on the original request.  In Servlet 2.4 (i.e.
>Tomcat 5.x) you can optionally configure which filters should be used on
>forwards, includes, or both, with suitable settings in web.xml.
>
>Craig
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Possible bug in RequestDispatcher?

Posted by "Craig R. McClanahan" <cr...@apache.org>.
In Servlet 2.3 (i.e. Tomcat 4.x), filters are *not* invoked on request
dispatcher calls -- only on the original request.  In Servlet 2.4 (i.e.
Tomcat 5.x) you can optionally configure which filters should be used on
forwards, includes, or both, with suitable settings in web.xml.

Craig

On Mon, 4 Nov 2002, Ryan Hoegg wrote:

> Date: Mon, 04 Nov 2002 13:33:41 -0500
> From: Ryan Hoegg <rh...@isisnetworks.net>
> Reply-To: Tomcat Developers List <to...@jakarta.apache.org>
> To: tomcat-dev@jakarta.apache.org
> Subject: Possible bug in RequestDispatcher?
>
> Hi,
>
> Before I post a bug report, I wanted to run a peculiar situation by the
> experts.
>
> I am creating some filters that verify that certain variables are in the
> session before allowing access to any page in my site.  There are
> currently two of them, and each forward the request to a form if a
> particular session variable is not set and if this is not the form
> submission.  They are using ((HttpServletRequest)
> request).getRequestDispatcher("/path/to/form1.html").forward(request,
> response) to accomplish this.
>
> Something is broken, and if it's in my code I am missing it.  I have
> these filters mapped to /* and here is the peculiar behavior:
> 1. If I point my browser at "/", I get the desired HTML page.
> 2. If I point at a servlet I have mapped, I get what looks like an HTML
> template page.
> 3. If I point at a static HTML file I have in the "/" I get a good chunk
> of the beginning of the HTML page and that's it.
>
> My web.xml is simpler than simple, I described it above except for the
> single servlet mapping. ("/Display")
>
> I appreciate any insights you can provide!
> --
> Ryan Hoegg
> ISIS Networks
> http://www.isisnetworks.net
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>