Discussions

Web tier: servlets, JSP, Web frameworks: JSP Tomcat Error

  1. JSP Tomcat Error (1 messages)

    Hi

    I have a JSP runnning well in JavaWebServer. When I tried to run it in TomCat I get the next error:

    Internal Servlet Error:
    java.lang.IllegalStateException: No puedo reenviar como OutputStream o el Writer ha sido ya obtenido
    at org.apache.tomcat.core.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:130)
    at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:357)
    at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:381)
    at Geography.Zone._0002fGeography_0002fZone_0002fModZone_0002ejspModZone_jsp_1._jspService(_0002fGeography_0002fZone_0002fModZone_0002ejspModZone_jsp_1.java, Compiled Code)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:174)
    at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
    at org.apache.jasper.runtime.JspServlet.service(JspServlet.java, Compiled Code)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java, Compiled Code)
    at org.apache.tomcat.core.ContextManager.service(ContextManager.java, Compiled Code)
    at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java, Compiled Code)
    at org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java, Compiled Code)
    at java.lang.Thread.run(Thread.java, Compiled Code)

    Any idea about what is happening???

    Thx

    Threaded Messages (1)

  2. JSP Tomcat Error[ Go to top ]

    I don't speak Spanish, but babelfish.altavista.com says this is: "I cannot reenviar as OutputStream or the Writer already has been obtained" (I guess it couldn't handle "reenviar").

    The error shows up when you are doing a JSP forward.
    You are getting an IllegalStateException. The JSP
    spec says:
    "If the page output was unbuffered and anything has been written to it, an attempt to forward
    the request will result in an IllegalStateException."

    Since it works for you in Java Web Server, but not in Tomcat, I'd say this might be happening:

    You've already written output to the client, and now
    you are trying to forward. Some kind of buffering happening in JWS meant the output hadn't been written at that point, so the forward worked... but the buffering isn't the same in Tomcat.

    So check your code and see if you have already written something.

    I usually avoid this by doing any JSP forwards or redirects at the top of my JSP pages, leaving regular HTML and the rest of the presentation lower down on the page. Basically, it's "check first if we are going somewhere else, otherwise write the page."

    Hope that helps.