tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: requestdispatcher with tags
Date Fri, 11 Jan 2002 06:34:13 GMT

On Thu, 10 Jan 2002, Scott Walter wrote:

> Date: Thu, 10 Jan 2002 19:38:58 -0800 (PST)
> From: Scott Walter <>
> Reply-To: Tomcat Users List <>
> To:
> Subject: requestdispatcher with tags
> I am trying to use Tomcat 4 to
> equestDispatcher.include() with a servlet that I have
> written which returns a gif image.
> However when I have the following code in the
> doStartTag() I get nothing:
> RequestDispatcher rd =
> pageContext.getRequest().getRequestDispatcher("/path/to/my/servlet");
> rd.include(pageContext.getRequest(),pageContext.getResponse());
> Any clues?  I can successfuly include a jsp page in
> the tag but not my servlet

Is your servlet really generating the binary GIF image directly?  If so,
it is nearly impossible to believe that you really WANT this included
directly in the output from your JSP page.  Most people would want their
tag to generate an <img> tag with the right source URL so that the browser
would request the dynamically created image.

What's actually happening is most likely your servlet trying to call
response.getOutputStream() -- so that it can write binary data -- and
getting an IllegalStateException because the JSP page has already called
response.getWriter() on the same request (because it wants to do character

I suspect you really want your tag to generate something like this:

  String url = ... URL to retrieve the dynamically generated image ...
  JspWriter out = pageContext.getOut();
  out.println("<img src='" + url + "'>");

where the URL you create calls your image-generating servlet directly.

> Scott

Craig McClanahan

To unsubscribe:   <>
For additional commands: <>
Troubles with the list: <>

View raw message