You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by Ameet Savant <as...@microimages.com> on 2000/10/09 23:19:49 UTC

IIS Tomcat

Hi,

I have been trying to run IIS4.0/Tomcat 3.1/JDK1.2.2 and there seems to be a
peculiar problem.

Whenever I type http://hostname.com/examples IE5 gives me the familiar
download save/run dialog? Standalone work fine and I haven't tried an
in-process yet. I wonder what is wrong?


Re: Header&footer filter (tomcat 4.0-m2)

Posted by Arvi Leino <ar...@suvi.kas.utu.fi>.
On Thu, 12 Oct 2000, Craig R. McClanahan wrote:
> It is not allowed to call request.getRequestDispatcher() from within a
> Filter,
> because you are not running inside a servlet at that moment (I will make
> sure this
> clarification gets added to the spec).
>
> - -
> 
> When I get a chance to write one, I will include an example of this sort
> of thing
> in Tomcat.

Thanks! What about setting request attribute for original request, calling
template jsp and template calling original request?

Arvi


Re: Header&footer filter (tomcat 4.0-m2)

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
arvleino@suvi.kas.utu.fi wrote:

> Why won't this filter work? Requested page is /test.jsp
>
> -----------------------------------
> public void doFilter(ServletRequest request, ServletResponse response)
>       throws IOException, ServletException {
>          RequestDispatcher
> disp=request.getRequestDispatcher("/header.html");
>          disp.include(request, response);
>
>          Filter next = filterConfig.getNext();
>          next.doFilter(request, response);
>
>          disp=request.getRequestDispatcher("/footer.html");
>          disp.include(request, response);
>       }
> -----------------------------------
>
> It throws an exception:
>
> java.lang.IllegalStateException: getOutputStream() has already been called
> for this response
>         at
> org.apache.catalina.connector.ResponseBase.getWriter(ResponseBase.java:636)
>         at
> javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:133)
>         at beans.RespWrapper.getWriter(RespWrapper.java:27)
>         at
> org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:166)
>         at
> org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:158)
>         at
> org.apache.jasper.runtime.JspWriterImpl.flush(JspWriterImpl.java:205)
> ...
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: general-help@jakarta.apache.org

It is not allowed to call request.getRequestDispatcher() from within a
Filter,
because you are not running inside a servlet at that moment (I will make
sure this
clarification gets added to the spec).

If you want to use a filter to add header/footer text, you will need to
use the
following strategy in your doFilter() method:

* Read the text of your header into an internal buffer (or at
  least count the characters so you know what the ultimate
  content length will be.

* Create a wrapper around the response object you received
  (extends javax.servlet.http.HttpServletResponseWrapper)
  that will be passed on to the rest of the filter chain.

* This wrapper should just buffer up the output created by the
  servlet itself.

* After the servlet returns, figure out how many characters are
  in the footer text as well.

* On the real response object:

    - Set the content length to the sum of the three sizes
      (header text, text returned by the servlet, and footer text)

    - Write all the text (header, servlet, footer) in order

When I get a chance to write one, I will include an example of this sort
of thing
in Tomcat.

Craig McClanahan

====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat

Header&footer filter (tomcat 4.0-m2)

Posted by ar...@suvi.kas.utu.fi.
Why won't this filter work? Requested page is /test.jsp

-----------------------------------
public void doFilter(ServletRequest request, ServletResponse response)
      throws IOException, ServletException {
         RequestDispatcher 
disp=request.getRequestDispatcher("/header.html");
         disp.include(request, response);
      
         Filter next = filterConfig.getNext();
         next.doFilter(request, response);
      
         disp=request.getRequestDispatcher("/footer.html");
         disp.include(request, response);
      }
-----------------------------------

It throws an exception:

java.lang.IllegalStateException: getOutputStream() has already been called
for this response
	at
org.apache.catalina.connector.ResponseBase.getWriter(ResponseBase.java:636)
	at
javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:133)
	at beans.RespWrapper.getWriter(RespWrapper.java:27)
	at
org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:166)
	at
org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:158)
	at
org.apache.jasper.runtime.JspWriterImpl.flush(JspWriterImpl.java:205)
...


Re: IIS Tomcat

Posted by Ameet Savant <as...@microimages.com>.
Okay people,

Apparently no one had this problem before. However since I have found a
solution to this problem I am posting the answer incase if someone as dumb
as me encounters it again.

The problem is that the virtual directory that you create for the ISAPI
filter has read access. IIS gives priority to reading(hence downloading) the
directory over executing it. The soultion is to remove the read access and
keep it only executable. (One would think that if you want the user to be
able to access your servlets you would give read access... think again)

I think the tomcat-IIS docs should be updated to this effect

Ameet

----- Original Message -----
From: Ameet Savant <as...@microimages.com>
To: <ge...@jakarta.apache.org>
Sent: Monday, October 09, 2000 4:19 PM
Subject: IIS Tomcat


> Hi,
>
> I have been trying to run IIS4.0/Tomcat 3.1/JDK1.2.2 and there seems to be
a
> peculiar problem.
>
> Whenever I type http://hostname.com/examples IE5 gives me the familiar
> download save/run dialog? Standalone work fine and I haven't tried an
> in-process yet. I wonder what is wrong?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: general-help@jakarta.apache.org
>