<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: IllegalStateException while using JSP</title> <atom:link href="http://iderror.com/errors/java/java-jsp/illegalstateexception-while-using-jsp/feed/" rel="self" type="application/rss+xml" /><link>http://iderror.com/errors/java/java-jsp/illegalstateexception-while-using-jsp/</link> <description>You have errors, we have solutions!</description> <lastBuildDate>Fri, 10 Jun 2011 15:06:54 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.2.1</generator> <item><title>By: admin</title><link>http://iderror.com/errors/java/java-jsp/illegalstateexception-while-using-jsp/comment-page-1/#comment-7955</link> <dc:creator>admin</dc:creator> <pubDate>Fri, 20 Mar 2009 10:28:59 +0000</pubDate> <guid
isPermaLink="false">http://localhost/idError/?p=8027#comment-7955</guid> <description>a. For servlets, the easiest way to avoid this is to branch the code in your service method in such a way as to insure that calls to HttpServletResponse.sendRedirect or RequestDispatcher.forward are always the last call made before the end of the method. This can be achieved by adding a return call just after either of these.Example:public void doGet(HttpServletRequest  request,
HttpServletResponse response) throws ServletException, IOException{if(&quot;client&quot;.equals(request.getParameter(&quot;user_type&quot;))){
response.sendRedirect(&quot;client-screen.jsp&quot;);
return;  // &lt;-------  This return statement prevents any further writing to the outputStream
}
//
// Other code that may write to the outputStream....
//
}b. It is impossible to redirect from within the middle of a JSP page. Check this and correct the code.
c. The simple solution to this problem is to always us a servlet for streaming binary data. </description> <content:encoded><![CDATA[<p>a. For servlets, the easiest way to avoid this is to branch the code in your service method in such a way as to insure that calls to HttpServletResponse.sendRedirect or RequestDispatcher.forward are always the last call made before the end of the method. This can be achieved by adding a return call just after either of these.</p><p>Example:</p><p>public void doGet(HttpServletRequest  request,<br
/> HttpServletResponse response) throws ServletException, IOException{</p><p> if(&#8220;client&#8221;.equals(request.getParameter(&#8220;user_type&#8221;))){<br
/> response.sendRedirect(&#8220;client-screen.jsp&#8221;);<br
/> return;  // <&#8212;&#8212;-  This return statement prevents any further writing to the outputStream<br
/> }<br
/> //<br
/> // Other code that may write to the outputStream&#8230;.<br
/> //<br
/> }</p><p>b. It is impossible to redirect from within the middle of a JSP page. Check this and correct the code.<br
/> c. The simple solution to this problem is to always us a servlet for streaming binary data.</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: iderror.com @ 2012-02-09 02:56:54 -->
