You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by kenneth topp <ca...@prodigy.net> on 2000/10/13 02:07:56 UTC

Re: [tomcat-users] Exception thrown when Forwarding

Anand,

Make it the very top line of your jsp.  If you've already sent some print
lines, it's too late.  you can examine the compiled to java version of
your jsp to see that there is output above the redirect attempt.

Alternativly, you can do this via interceptor/servlet and avoid this
mess...

I don't know any rational for behavior (it's in the spec though).  It
seems like simply a performance requirment that many users would happily
turn off.  Did that surprise anyone ;)

Kenneth Topp

---
 to unsubscribe: tomcat-user-unsubscribe@jakarta.apache.org
 for more info: http://jakarta.apache.org/getinvolved/mail.html

On Thu, 12 Oct 2000, Anand Prasad wrote:

> Hi
> 
> I store a session variable and basically check in every page whether that 
> varibale contains any value.
> 
> When the user directly wants to enter the url without logging, I would like 
> to redirect him to login page.
> 
> Here is code snippet.
> //
> <% if((String)session.getValue("loginId")==null){ %>
>       <jsp:forward page="/login.htm" />
> <% } %>
> 
> It throws up an exception in apache and tomcat.
> 
> I think I am making very stupid mistake...but unable to figure it.
> 
> Any suggestions, Thanks
> 
> javax.servlet.ServletException: Cannot forward as OutputStream or Writer has 
> already been obtained
>         at java.lang.Throwable.fillInStackTrace(Native Method)
>         at java.lang.Throwable.fillInStackTrace(Compiled Code)
>         at java.lang.Throwable.(Compiled Code)
>         at java.lang.Exception.(Compiled Code)
>         at javax.servlet.ServletException.(ServletException.java:161)
>         at 
> org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:386)
>         at 
> dv._0002fdv_0002fsecurity_0002ejspsecurity_jsp_2._jspService(_0002fdv_0002fsecurity_0002ejspsecurity_jsp_2.java:92)
>         at 
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
>         at javax.servlet.http.HttpServlet.service(Compiled Code)
>         at 
> org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:174)
>         at org.apache.jasper.runtime.JspServlet.serviceJspFile(Compiled 
> Code)
>         at org.apache.jasper.runtime.JspServlet.service(Compiled Code)
>         at javax.servlet.http.HttpServlet.service(Compiled Code)
>         at org.apache.tomcat.core.ServletWrapper.handleRequest(Compiled 
> Code)
>         at 
> org.apache.tomcat.core.RequestDispatcherImpl.include(RequestDispatcherImpl.java:262)
>         at org.apache.jasper.runtime.PageContextImpl.include(Compiled Code)
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
> 
> Share information about yourself, create your own public profile at 
> http://profiles.msn.com.
>