Strange Illegal State Exception

Hello all,
I've been writing a large webapp for a while and have suddenly started getting this exception. It turns up in the web server logs, occurs in the middle of a loop, and although all exceptions in my servlet are caught and forwarded to a generic error page, this exception causes the output to stop - leaving just the already-output HTML on the page. I guess this is because it's a runtime exception.
I know this can occur by calling getWriter() and getOutputStream() in the same servlet, but I've done nothing except println() on my PrintWriter after using getWriter() to retrieve it.
Anyone got any ideas on why this might occur?
Thanks!
Gemma

Here's the loop in which the error occurs:
           for(int i=0;i<theVector.size();i++)
          CustomObject temp = (CustomObject)theVector.elementAt(i);
          if(user.hasMultipleAttributes())
            if(i==0)
              out.println("<tr><td colspan=\"6\">For <b>" + temp.getCountry() + "</b></td></tr><tr><td colspan=\"6\"><br></td></tr>");
            else
              if(!temp.getCountry().equals(lastCountry))
                out.println("<tr><td colspan=\"6\">For <b>" + temp.getCountry() + "</b></td></tr><tr><td colspan=\"6\"><br></td></tr>");
            lastCountry = temp.getCountry();
          out.println("<tr><td>" + temp.getStory() + "</td>");
          out.println("<td>" + temp.getLanguage() + "</td>");
          if(currentUser.hasMultipleAttributes())
            out.println("<td>" + temp.getCountry() + "</td>");
          out.println("<td>" + temp.getRequestDate() + "</td>");
          out.println("<td>" + temp.getPublishDate() + "</td>");
          if(temp.isComplete())
            out.println("<td><img src=\"" + URLContainer.getTickImageURL() + "\"></img></td>");
          else
            out.println("<td><form method=\"post\" action=\"" + URLContainer.getCompleteStoryDetailsURL() + "\"><input type=\"hidden\" name=\"storyname\" value=\"" + temp.getStoryName() + "\"><input type=\"hidden\" name=\"language\" value=\"" + temp.getLanguage() + "\"><input type=\"hidden\" name=\"country\" value=\"" + temp.getCountry() + "\"><input type=\"submit\" value=\"Complete Usage Details\"></form></td>");
          out.println("</tr>");
          CustomObject temp2 = (CustomObject)theVector.elementAt(i+1);
          if(!lastCountry.equals(temp2.getCountry()))
            out.println("<tr><td colspan=\"6\"><br></td></tr>");
           } I can't see anything in here which would cause such an error. I don't pass the PrintWriter (out) anywhere... I don't set the buffer size and I don't believe that the PrintWriter is returned in autoFlush mode (not 100% sure though).
For redirects, I tend to use HttpServletResponse.sendRedirect().
Thanks
Gemma

Similar Messages

  • Illegal state exception in filters can any help me plzzzzzzz

    i want to check the clients status i mean whether the request is coming from new client or already using client , if clients request is new one then the filter has to redirect to some other login page and also if the request is asked to access the authenticated resource then also he want to force to redirect to login page.If the user is logged in and his session is not expired and if session is valid then he can access the requested url as per his role....can any one suggest the code plzzzzzzzzz
    here is my code but iam getting the illegal state exception as shown below...
    package uk.co.lex.interactive.authentication.action;
    import java.io.IOException;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    public class AuthenticationFilter implements Filter {
    private FilterConfig filterConfig=null;
    HttpSession session=null;
         public void init(FilterConfig filterConfig) throws ServletException {
              //TODO Auto-generated method stub
              this.filterConfig=filterConfig;
              System.out.println("---Authentication filter initialized---");
         public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
              // TODO Auto-generated method stub
              HttpServletRequest req=(HttpServletRequest)request;
              HttpServletResponse res=(HttpServletResponse)response;
                   String reqSessId=req.getRequestedSessionId();
              if(reqSessId!=null)
                   {System.out.println("-------session is valid and the same client is using the resource111---");
                         if(req.isRequestedSessionIdValid())
                            System.out.println("-------session is valid and the same client is using the resource222---");
                            System.out.println("---requested sessid"+reqSessId);
                           if(req.isRequestedSessionIdFromCookie()||req.isRequestedSessionIdFromURL())
                                System.out.println("-------session is valid and the same client is using the resource333---");
              }else
              res.sendRedirect(req.getContextPath()+"/"+"checkUser.do");
                        System.out.println("------it is new session so it redirected to loginpage from authentication filter-------");
              else
                   res.sendRedirect(req.getContextPath()+"/"+"checkUser.do");
                   System.out.println("------it is new session so it redirected to loginpage from authentication filter-------");
              chain.doFilter(request,response);
         public void destroy() {
              // TODO Auto-generated method stub
              this.filterConfig=null;
              System.out.println("-----authentication filter destroyed---");
    11:03:18,693 ERROR [[action]] Servlet.service() for servlet action threw exception
    java.lang.IllegalStateException: Cannot create a session after the response has been committed
         at org.apache.catalina.connector.Request.doGetSession(Request.java:2195)
         at org.apache.catalina.connector.Request.getSession(Request.java:2017)
         at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:822)
         at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)
         at org.apache.struts.action.RequestProcessor.processLocale(RequestProcessor.java:621)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:177)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
         at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at uk.co.lex.interactive.authentication.action.AuthenticationFilter.doFilter(AuthenticationFilter.java:63)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
         at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
         at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
         at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
         at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
         at java.lang.Thread.run(Thread.java:595)

    I don't know that this is the root cause of your problem, but it certainly could be. When comparing two strings, you need to use the .equals() method, not ==.
    (except in the null case, where checking for null with == is perfectly okay).
    if (ViewProtectedPage.getValue("trycount").equals("1")
    ..etc
    Some other notes... use if/else if/else rather than a whole bunch of ifs, since all your statements are mutually exclusive. Maybe even put those lower ifs inside your outer "else" since you're obviously not going to reach them after a sendRedirect(). On that same note, place a return; after the sendRedirect() to state that the rest of the page need not be loaded/executed.

  • Illegal State Exception in JSP login

    I had a working log in/check password systems for a low security application. User types in username and password and this is sent to the checkpassword.jsp. Using Server variables I counted the number of attempts and if it was more than three, they were not allowed to try again that session. When I moved this page to newer version of Tomcat running in Apache rather than over IIS, my simple counting function no longer works and I can't for the life of me understand why I'm getting an Illegal State Exception with the following code:
    java.sql.ResultSet RS=statement.executeQuery("Select WUUSER, WUPWD FROM WEBUSER WHERE WUUSER='"+ (request.getParameter("username").toUpperCase()) + "' AND WUPWD= '" + (request.getParameter("password")) +"'");
    HttpSession ViewProtectedPage = request.getSession(true);
    HttpSession UserSession = request.getSession(true);
    if (RS.next())
    ViewProtectedPage.putValue("password","correct");
    //HttpSession UserSession = request.getSession(true);
    //allows username to be entered in upper or lower case
    UserSession.putValue("username",(request.getParameter("username")).toUpperCase());
    response.sendRedirect("tracking.jsp");
    else
    ViewProtectedPage.putValue("password","false");
    if (ViewProtectedPage.getValue("trycount")==null) {
    ViewProtectedPage.putValue("trycount","1");
    response.sendRedirect("loadtrackbadlogin.html");
    if (ViewProtectedPage.getValue("trycount")=="1") {
    ViewProtectedPage.putValue("trycount","2");
    response.sendRedirect("loadtrackbadlogin.html");
    if (ViewProtectedPage.getValue("trycount")=="2") {
    ViewProtectedPage.putValue("trycount","3");
    response.sendRedirect("loadtrackbadlogin.html");
    if (ViewProtectedPage.getValue("trycount")=="3") {
    response.sendRedirect("noentry.html");
    RS.close();
    It works fine if the user uses the proper username and password but crashes on me if they use the wrong info. I think it has something to do with my initialization of the user variables.

    I don't know that this is the root cause of your problem, but it certainly could be. When comparing two strings, you need to use the .equals() method, not ==.
    (except in the null case, where checking for null with == is perfectly okay).
    if (ViewProtectedPage.getValue("trycount").equals("1")
    ..etc
    Some other notes... use if/else if/else rather than a whole bunch of ifs, since all your statements are mutually exclusive. Maybe even put those lower ifs inside your outer "else" since you're obviously not going to reach them after a sendRedirect(). On that same note, place a return; after the sendRedirect() to state that the rest of the page need not be loaded/executed.

  • Illegal State Exception with response.sendRedirect

    Hi all,
    When i am using response.sendRedirect(address), It is giving illegal state exception at few places. At few places it is working fine. I couldnt trace the reason.
    I am using tomcat 4.1 with SSL configured for the server. Will session tracking effect response.sendRedirect(address)'s ability any way?
    Can any body help me out...
    Thanks in advance...
    krish

    I believe this quite often occurs when you have tried to send some kind of response already. I.E. you should not have sent anything to the client when you call this method so start by looking for any write's you have prior to the sendRedirect().
    Ted.

  • Illegal State Exception ; Resource resolver already closed

    Hi
         In my component I have a page resource. When I am trying to get the image resource of the same as below it is throwing me an Illegal State exception
    Resource resource = page.getContentResource("image");
    My error stack trace is as follows
                     Eventhough i am not closing any resource ; it is giving me illegal state exception for the resource. Please help me in finding a solution for this.
    Thanks
    Veena

    Are you calling the right path?
    The call to page.getContentResource("image") will end up calling the following:
    resource.getResourceResolver().getResource(resource, “jcr:content/image”);

  • JComboBox Illegal state Exception problem

    Hello Everyone,
    I have the following code for creating a combobx in Eclipse. Now whenever eclipse reloads it gives an Illegal state exception error. When I remove the code and rewrite the same code it works fine. Any idea on how to fix this problem??
    Things are normal and there is no problem when I dont initialize the combobox.
    private JComboBox getJComboBoxNumOfSteps() {
           if (jComboBoxNumOfSteps == null) {
         String[] valStrings = { "1", "2", "3", "4", "5", "6", "7", "8", "9" ,"10","11","12","13","14","15","16","17"};
         jComboBoxNumOfSteps = new JComboBox(valStrings);
         jComboBoxNumOfSteps.setPreferredSize(new java.awt.Dimension(80,25));
         jComboBoxNumOfSteps.addActionListener(new java.awt.event.ActionListener() {
         public void actionPerformed(java.awt.event.ActionEvent e) {
                                              Integer i = new Integer(jComboBoxNumOfSteps.getSelectedIndex()+1);
                              jTextArea.append(i.toString());
              jTextArea.append("\n");
            return jComboBoxNumOfSteps;
    }Thanx Amar

    Depends what context, and who's exception....
    I'll go with my best guess here though.
    You're using wait() and notify() and or notifyAll() with some threads. In this case the IllegalStateException is being thrown because you are calling one of these methods on an object you are not holding the lock for. Here are some good resources.
    Doug Lea's site.
    http://g.cs.oswego.edu
    and the book
    http://java.sun.com/docs/books/cp/
    if not,.... oh well, describe your problem better.
    -Spinoza

  • Please clarify on Illegal state exception

    Dear All pl explain Illegal state exception occurs in some program why. and what is the solution.

    Hi,
    This exception is thrown when a method is invoked at an illegal or inappropriate time or if the provider is not in an appropriate state for the requested operation.
    In servlets, for example, you have a method forward() in the RequestDispatcher class, which forwards the request to another resource for processing. This method should be called before the response is committed, else it throws IllegalStateException.

  • af:attribute Illegal state exception on tomcat

    I am getting Illegal state exception, when I use <af:attribute> referencing a row variable in treeTable :
    java.lang.IllegalStateException
         com.sun.faces.context.FacesContextImpl.assertNotReleased(FacesContextImpl.java:382)
         com.sun.faces.context.FacesContextImpl.getApplication(FacesContextImpl.java:120)
         oracle.adfinternal.view.faces.taglib.AttributeTag.doStartTag(AttributeTag.java:94)
         org.apache.jsp.ObjectList2_jspx._jspx_meth_af_attribute_0(ObjectList2_jspx.java:767)
         org.apache.jsp.ObjectList2_jspx._jspx_meth_af_commandLink_4(ObjectList2_jspx.java:749)
         org.apache.jsp.ObjectList2_jspx._jspx_meth_af_column_3(ObjectList2_jspx.java:543)
         org.apache.jsp.ObjectList2_jspx._jspx_meth_af_treeTable_0(ObjectList2_jspx.java:232)
         org.apache.jsp.ObjectList2_jspx._jspx_meth_af_form_0(ObjectList2_jspx.java:206)
         org.apache.jsp.ObjectList2_jspx._jspx_meth_afh_body_0(ObjectList2_jspx.java:188)
         org.apache.jsp.ObjectList2_jspx._jspx_meth_afh_html_0(ObjectList2_jspx.java:152)
         org.apache.jsp.ObjectList2_jspx._jspx_meth_f_view_0(ObjectList2_jspx.java:126)
         org.apache.jsp.ObjectList2_jspx._jspService(ObjectList2_jspx.java:97)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
         oracle.adfinternal.view.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:134)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
         oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._doFilterImpl(AdfFacesFilterImpl.java:266)
         oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:164)
         oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:87)
         oracle.adfinternal.view.faces.webapp.FacesFilter.doFilter(FacesFilter.java:89)
    If I use f:attribute, there is no exception, but also the attribute is not created. If I use f:attribute or af:atribute with a string value, it works OK.
    Here is my page:
    <?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:afh="http://xmlns.oracle.com/adf/faces/EA14/html"
    xmlns:af="http://xmlns.oracle.com/adf/faces/EA14" >
    <jsp:directive.page contentType="text/html;charset=utf-8"/>
    <f:view>
         <afh:html>
         <afh:head title="Main">
              <meta http-equiv="Content-Type"
                   content="text/html; charset=windows-1250"></meta>
         </afh:head>
         <afh:body>
              <af:form>
    <af:treeTable var="row" value="#{s.userObjectTreeModel}">
         <f:facet name="nodeStamp">
              <af:column>
                   <f:facet name="header">
                        <af:outputText value="User Objects" />
                   </f:facet>
                   <af:outputText value="#{row.item.userObjectName}" />
              </af:column>
         </f:facet>
         <af:column>
              <f:facet name="header">
                   <af:outputText value="Type" />
              </f:facet>
                   <af:outputText value="Micromart" rendered="#{row.item.micromart}" />
                   <af:outputText value="Group" rendered="#{row.item.userGroup}" />
                   <af:outputText value="Object" rendered="#{row.item.userObject}" />
         </af:column>
         <af:column>
              <f:facet name="header">
                   <af:outputText value="Status" />
              </f:facet>
                   <af:outputText value="#{row.item.status}" />
         </af:column>
         <af:column>
              <f:facet name="header">
                   <af:outputText value="Actions" />
              </f:facet>
              <af:commandLink text="Edit" actionListener="#{s.selectUserObject}"
                   rendered="#{row.item.userObject}">
                   <af:attribute name="item" value="#{row.item.userObjectName}" />
              </af:commandLink>          
         </af:column>
    </af:treeTable>
              </af:form>
         </afh:body>
         </afh:html>
    </f:view>
    </jsp:root>
    and here is server.xml :
    <?xml version = '1.0' encoding = 'ISO-8859-1'?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <!-- Faces API parameter -->
    <context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
    <!--param-value>server</param-value-->
    </context-param>
    <!-- ADF Faces by default uses an optimized client-side state saving
    mechanism. To disable that, uncomment the following -->
    <!--context-param>
    <param-name>oracle.adf.view.faces.CLIENT_STATE_METHOD</param-name>
    <param-value>all</param-value>
    </context-param-->
    <!-- Whether or not to turn on Oracle DMS metrics -->
    <!-- set to "true" to enable DMS metrics in an OC4J environment. -->
    <!-- Then you can go to
    http://<hostname>:<port>/<context-root>/servlet/Spy -->
    <context-param>
    <param-name>oracle.adf.view.faces.ENABLE_DMS_METRICS</param-name>
    <param-value>false</param-value>
    </context-param>
    <!-- Faces Filter -->
    <filter>
    <filter-name>faces</filter-name>
    <filter-class>oracle.adfinternal.view.faces.webapp.FacesFilter</filter-class>
    <init-param>
    <param-name>faces-servlet-url-pattern</param-name>
    <param-value>/faces/*</param-value>
    </init-param>
    </filter>
    <filter>
    <filter-name>adfFaces</filter-name>
    <filter-class>oracle.adf.view.faces.webapp.AdfFacesFilter</filter-class>
    </filter>
    <!-- Faces Filter Mappings -->
    <filter-mapping>
    <filter-name>faces</filter-name>
    <url-pattern>*.jspx</url-pattern>
    </filter-mapping>
    <filter-mapping>
    <filter-name>adfFaces</filter-name>
    <servlet-name>facesS</servlet-name>
    </filter-mapping>
    <!-- Faces Servlet -->
    <servlet>
    <servlet-name>facesS</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    </servlet>
    <!-- On some version of OC4J, the following is needed when using jsf 1.0 -->
    <!--servlet>
    <servlet-name>jsp</servlet-name>
    <servlet-class>oracle.jsp.runtimev2.JspServlet</servlet-class>
    <init-param>
    <param-name>tags_reuse_default</param-name>
    <param-value>none</param-value>
    </init-param>
    </servlet-->
    <!-- Faces Servlet Mappings -->
    <servlet-mapping>
    <servlet-name>facesS</servlet-name>
    <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <!-- Welcome Files -->
    <welcome-file-list>
    <welcome-file>index.jspx</welcome-file>
    </welcome-file-list>
    <!-- ADF Faces Tag Library -->
    <taglib>
    <taglib-uri>http://xmlns.oracle.com/adf/faces/EA14</taglib-uri>
    <taglib-location>/WEB-INF/af.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>http://xmlns.oracle.com/adf/faces/EA14/html</taglib-uri>
    <taglib-location>/WEB-INF/afh.tld</taglib-location>
    </taglib>
    <!-- Faces Core Tag Library -->
    <taglib>
    <taglib-uri>http://java.sun.com/jsf/core</taglib-uri>
    <taglib-location>/WEB-INF/jsf_core.tld</taglib-location>
    </taglib>
    <!-- Faces Html Basic Tag Library -->
    <taglib>
    <taglib-uri>http://java.sun.com/jsf/html</taglib-uri>
    <taglib-location>/WEB-INF/html_basic.tld</taglib-location>
    </taglib>
    <!-- Survey Demo (Custom) Tag Library -->
    <taglib>
    <taglib-uri>http://xmlns.oracle.com/adf/faces/EA14/demo</taglib-uri>
    <taglib-location>/WEB-INF/survey.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>http://xmlns.oracle.com/adffacesdemo</taglib-uri>
    <taglib-location>/WEB-INF/uixdemo.tld</taglib-location>
    </taglib>
    </web-app>
    I use Tomcat 5.0.18 (embeded in Eclipse for web) and ADF Faces ea14 (with ea13 was the same problem.)
    Thanks for any hints...

    When I refresh the page after this exception, the content is displayed correctly. When I make new request on this page, I get new Illegal state exception, after the refresh the content is displayed correctly again ...

  • Illegal State Exception with Servlets

    Hi Friends,
    I am using RequestDispatcher to forwrd my request from one servlet to another
    Here's the code
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class TryServlet extends HttpServlet
    public void service(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String url="jdbc:odbc:con";
    Connection con= DriverManager.getConnection(url,"scott","tiger");
    Statement stmt=con.createStatement();
    ResultSet rst=stmt.executeQuery("select * from Projects");
    response.setContentType("text/html");
    PrintWriter out=response.getWriter();
    while (rst.next())
    String firstname=rst.getString("PIN");
    String lastname=rst.getString("ProjectTitle");
    out.println("<p> Name:"+firstname+" "+lastname+"");
    con.close();
    RequestDispatcher rd=getServletContext().getNamedDispatcher("HelloServlet");
    rd.forward(request,response);
    return;
    catch(Exception e)
    e.printStackTrace();
    I m getting the error
    java.lang.IllegalStateException: Cannot forward after response has been committed
    i need to include the two rows of tables before i forwad the request to HelloServlet
    What needs to be done?
    thanx
    Pooja

    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class TryServlet extends HttpServlet
    public void service(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String url="jdbc:odbc:con";
    Connection con= DriverManager.getConnection(url,"scott","tiger");
    Statement stmt=con.createStatement();
    ResultSet rst=stmt.executeQuery("select * from Projects");
    response.setContentType("text/html");
    PrintWriter out=response.getWriter();
    while (rst.next())
    String firstname=rst.getString("PIN");
    String lastname=rst.getString("ProjectTitle");
    out.println("<p> Name:"+firstname+" "+lastname+"");
    con.close();
    RequestDispatcher rd=getServletContext().getNamedDispatcher("HelloServlet");
    rd.forward(request,response);
    return;
    catch(Exception e)
    e.printStackTrace();
    please explain your problem for more details???

  • Illegal state exception

    I am often getting the exception shown below
    javax.jms.IllegalStateException: Operation not allowed
    [22/Jun/2006:17:08:15] WARNING (10553): CORE3283: stderr:      at com.sun.enterprise.jms.SessionWrapperEjb.commit(SessionWrapperEjb.java:55)
    [22/Jun/2006:17:08:15] WARNING (10553): CORE3283: stderr:      at com.transversalnet.grid.util.QueueHandler.pushMessage(QueueHandler.java:362)
    [22/Jun/2006:17:08:15] WARNING (10553): CORE3283: stderr:      at com.transversalnet.grid.util.QueueHandler.pushMessageForSending(QueueHandler.java:118)
    [22/Jun/2006:17:08:15] WARNING (10553): CORE3283: stderr:      at com.transversalnet.grid.module.user.UserUtil.pushToOriginatingServer(UserUtil.java:464)
    [22/Jun/2006:17:08:15] WARNING (10553): CORE3283: stderr:      at com.transversalnet.grid.handler.user.MsgUserHandler.createUser(MsgUserHandler.java:290)
    [22/Jun/2006:17:08:15] WARNING (10553): CORE3283: stderr:      at com.transversalnet.grid.handler.user.MsgUserHandler.handle(MsgUserHandler.java:183)
    [22/Jun/2006:17:08:15] WARNING (10553): CORE3283: stderr:      at com.transversalnet.grid.handler.user.UserHandler.handle(UserHandler.java:43)
    [22/Jun/2006:17:08:15] WARNING (10553): CORE3283: stderr:      at com.transversalnet.grid.ejb.processor.ProcessorBean.onMessage(ProcessorBean.java:83)
    [22/Jun/2006:17:08:15] WARNING (10553): CORE3283: stderr:      at com.sun.ejb.containers.MessageBeanContainer.onMessage(MessageBeanContainer.java:857)
    [22/Jun/2006:17:08:15] WARNING (10553): CORE3283: stderr:      at com.sun.ejb.containers.MessageBeanListenerConcurrent.onMessage(MessageBeanListenerConcurrent.java:20)
    [22/Jun/2006:17:08:15] WARNING (10553): CORE3283: stderr:      at com.sun.messaging.jmq.jmsclient.ServerSessionRunner.onMessage(ServerSessionRunner.java:139)
    [22/Jun/2006:17:08:15] WARNING (10553): CORE3283: stderr:      at com.sun.messaging.jmq.jmsclient.ServerSessionRunner.run(ServerSessionRunner.java:105)
    [22/Jun/2006:17:08:15] WARNING (10553): CORE3283: stderr:      at com.sun.messaging.jmq.jmsclient.SessionImpl.run(SessionImpl.java:2313)
    [22/Jun/2006:17:08:15] WARNING (10553): CORE3283: stderr:      at com.sun.enterprise.jms.SessionWrapperBase.run(SessionWrapperBase.java:199)
    [22/Jun/2006:17:08:15] WARNING (10553): CORE3283: stderr:      at com.iplanet.ias.ejb.containers.IASServerSessionImpl.run(IASServerSessionImpl.java:191)
    Any idea why it is happening
    Suneesh

    It appears that you are calling commit in your Message
    Driven bean ...
    This is not allowed per the EBJ specification (the container
    is responsible for committing or rolling back the action)

  • How to avoid illegal state exception in jsp/servlets

    Hi,
    Am working on jsps and servlets ,some times am getting Illegalstateexception,in what situations we will get this exception,can any one tell clearly about this exception..
    mani

    Since there's no other real supporting information you have out there, I can only take a wild stab at this...
    My guess is that you're trying to invoke methods on the server with your jsp code that isn't allowed. For example, I often work with a PDM software that will throw Illegalstateexceptions when I try to modify objects in the system that are not checked out. More than a java thing, this might be an issue with the servlets you're using. If your servlet is being provided by a vendor, you might want to check up on their API for more information about such an error occuring, or consult their technical support, if such a group exists.
    If this is your own servlet, I would suggest making sure that the methods you're trying to invoke are available for the servlet to invoke, which would also cause that exception.

  • How to avoid Illegal State Exception?

    Im using struts and develop in J2EE. My action class calls the ejb and returns to the actionClass and then to the jsp. This works once and the second time , i get IllegalStateException. But without recompiling when i restart ,my jboss and preform the previous activity , it works fine!!
    Does have an explanation and provide a solution?
    Thanks

    This is error snippet obtained!
    2007-10-09 10:47:05,984 WARN [org.apache.struts.action.RequestProcessor] Unhandled Exception thrown: class java.lang.IllegalStateException
    2007-10-09 10:47:05,984 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[].[action]] Servlet.service() for servlet action threw exception
    java.lang.IllegalStateException: No transaction.
         at org.jboss.tm.TxManager.rollback(TxManager.java:331)
         at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.rollback(ServerVMClientUserTransaction.java:134)
         at com.modulbio.struts.actionclasses.experiment.CreatePasteurExpPlatesAction.execute(CreatePasteurExpPlatesAction.java:463)
         at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
         at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
         at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
         at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:407)
         at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
         at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
         at java.lang.Thread.run(Thread.java:595)

  • Illegal state exception in Document Listener

    Hi folks,
    Iam getting the IllegalStateException when iam trying to update the document in the Document Listener.
    spec says iam not supposed to mutate the document in the document Listener.
    My requirement is that: when user types any java key word in JTextPane..I need to change it's color. I tried this in DocumentListener and CaretListener. But Iam getting following Exception:
    Exception occurred during event dispatching:
    java.lang.IllegalStateException: Attempt to mutate in notification
    at javax.swing.text.AbstractDocument.writeLock(AbstractDocument.java:971)
    is there any alternative way to do this?
    thanks in advance!!
    -TSR

    Take the code that you are using to update the document and submit it to Swing to run later, like this:
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        // your code goes here

  • Illegal State Exception when uploading file

              I am getting the following error in a jsp page that does a upload
              of a file. My enviorment is WL6.0 SP1 and it seems to occur
              when I do a pageContext.forward("xxx.jsp")
              java.lang.IllegalStateException: One of the getParameter family
              of methods calle
              d after reading from the ServletInputStream(), can't mix these
              two!
              at weblogic.servlet.internal.ServletRequestImpl.mergePostParams(ServletR
              equestImpl.java:664)
              at weblogic.servlet.internal.ServletRequestImpl.parseQueryParams(Servlet
              RequestImpl.java:585)
              at weblogic.servlet.internal.ServletRequestImpl.parseQueryParams(Servlet
              RequestImpl.java:578)
              at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispat
              cherImpl.java:124)
              at weblogic.servlet.jsp.PageContextImpl.forward(PageContextImpl.java:111
              at jsp_servlet._processagencylogoselection._jspService(_processagencylog
              oselection.java:444)
              at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
              at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
              pl.java:213)
              at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
              rvletContext.java:1265)
              at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
              pl.java:1622)
              at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              >
              Any help would greatly be appreciated.
              

    Mike,
              You should not use request.getParameter before getInputStream as per servlet spec.
              Mike G wrote:
              > Yes I do within a servlet, but I don't understand why this would
              > occur though. Maybe it's because the content type is
              > multipart/x-mixed-replace;boundary=End????
              >
              > Mettu Kumar <[email protected]> wrote:
              > >Did you use request.getParameter before calling request.getInputStream
              > >?
              > >Looks like this is causing the error.
              > >
              > >Kumar.
              > >
              > >Mike G wrote:
              > >
              > >> I am getting the following error in a jsp page that
              > >does a upload
              > >> of a file. My enviorment is WL6.0 SP1 and it seems
              > >to occur
              > >> when I do a pageContext.forward("xxx.jsp")
              > >>
              > >> java.lang.IllegalStateException: One of the getParameter
              > >family
              > >> of methods calle
              > >> d after reading from the ServletInputStream(), can't
              > >mix these
              > >> two!
              > >> at weblogic.servlet.internal.ServletRequestImpl.mergePostParams(ServletR
              > >> equestImpl.java:664)
              > >> at weblogic.servlet.internal.ServletRequestImpl.parseQueryParams(Servlet
              > >> RequestImpl.java:585)
              > >> at weblogic.servlet.internal.ServletRequestImpl.parseQueryParams(Servlet
              > >> RequestImpl.java:578)
              > >> at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispat
              > >> cherImpl.java:124)
              > >> at weblogic.servlet.jsp.PageContextImpl.forward(PageContextImpl.java:111
              > >> )
              > >> at jsp_servlet._processagencylogoselection._jspService(_processagencylog
              > >> oselection.java:444)
              > >> at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
              > >> at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
              > >> pl.java:213)
              > >> at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
              > >> rvletContext.java:1265)
              > >> at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
              > >> pl.java:1622)
              > >> at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
              > >> at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              > >> >
              > >> Any help would greatly be appreciated.
              > >
              

  • There was a video error: java.lang.illegal state exception: the player is closed

    that message pop up when i tried to send video at whatsapp

    Hi prince2012,
    I followed the instruction on KB17217, but it doesnt work. does that instruction work for torch 9800 too?
    On the BlackBerry smartphone, open the Options screen.
      2.  Open Advanced Options. =====> no. 2 - 8 , mine doesnt have this option 
      3.  Open Applications.
      4.  Highlight the Flickr Uploader for BlackBerry smartphones application.
      5.  Press the Menu button.
      6.  Select Delete from the menu. 
      7.  Select Delete from the confirm menu.
      8.  Reset the BlackBerry smartphone, if prompted.
    OR
    Turn off content protection on the BlackBerry smartphone by completing the following steps:
      1.  On the BlackBerry smartphone, open the Options screen.
      2.  Open the Security Options screen.
      3.  Open the Open the General Settings option =====>mine doesnt have this option either
      4.  Select the Content Protection option and change it to Disabled.
      5.  Save the settings.

Maybe you are looking for

  • How can i see log in sm35 after i run my program  ?

    i ahve some problem in my recording  , but i cant get what screen couse to the error . i get message in the end of the session  "Start screen does not exist in batch input data". i try to fix ( remark or open some lines ) but i cant find the problem 

  • Scniwall 2400 GVC (vpn) is not working after FIPS Enable

    Hi ,Yesterday i have enabled FIPS Mode on my Sonicwall 2400 after that globle vpn is not working i i am getting following error which connecting:2015/07/10 16:17:52:918 Information x.x.x.x Phase 1 has completed.2015/07/10 16:17:52:918 Error x.x.x.x F

  • How to Hide / Unhide iGrid Applet

    I'm attempting to develop an irpt page which will feature two grids / applets.  The topmost grid will be visible upon initial load of the page.  Upon selecting a record from the top grid, I'd like to then unhide the bottom grid so that a user may sel

  • Get a document's content

    Hi everyone, I'm currently using LiveCycle ES 8.0 and am receiving a TIFF image as an input document (Document variable).  I need to take this document, get it's content (the image itself), and convert it to a String variable that I can store into a

  • I had a power loss, and now Firefox won't start on my XinXP machine. In processes list is firefox.exe, but no window ever opens

    I have both Firefox and Thunderbird - both are acting the same. When I double click the exe icon, a process starts, visible in the task manager, but no application ever shows up, in applications, nor any window appaears. Both were working earlier tod