Quantcast
Channel: Active questions tagged servlets - Stack Overflow
Viewing all articles
Browse latest Browse all 675

java.lang.IllegalStateException: Cannot (forward | sendRedirect | create session) after response has been committed

$
0
0

This method throws

java.lang.IllegalStateException: Cannot forward after response has been committed

and I am unable to spot the problem. Any help?

    int noOfRows = Integer.parseInt(request.getParameter("noOfRows"));    String chkboxVal = "";    // String FormatId=null;    Vector vRow = new Vector();    Vector vRow1 = new Vector();    String GroupId = "";    String GroupDesc = "";    for (int i = 0; i < noOfRows; i++) {        if ((request.getParameter("chk_select"+ i)) == null) {            chkboxVal = "notticked";        } else {            chkboxVal = request.getParameter("chk_select"+ i);            if (chkboxVal.equals("ticked")) {                fwdurl = "true";                Statement st1 = con.createStatement();                GroupId = request.getParameter("GroupId"+ i);                GroupDesc = request.getParameter("GroupDesc"+ i);                ResultSet rs1 = st1                        .executeQuery("select FileId,Description from cs2k_Files "+" where FileId like 'M%' and co_code = "+ ccode);                ResultSetMetaData rsm = rs1.getMetaData();                int cCount = rsm.getColumnCount();                while (rs1.next()) {                    Vector vCol1 = new Vector();                    for (int j = 1; j <= cCount; j++) {                        vCol1.addElement(rs1.getObject(j));                    }                    vRow.addElement(vCol1);                }                rs1 = st1                        .executeQuery("select FileId,NotAllowed from cs2kGroupSub "+" where FileId like 'M%' and GroupId = '"+ GroupId +"'"+" and co_code = "+ ccode);                rsm = rs1.getMetaData();                cCount = rsm.getColumnCount();                while (rs1.next()) {                    Vector vCol2 = new Vector();                    for (int j = 1; j <= cCount; j++) {                        vCol2.addElement(rs1.getObject(j));                    }                    vRow1.addElement(vCol2);                }                // throw new Exception("test");                break;            }        }    }    if (fwdurl.equals("true")) {        // throw new Exception("test");        // response.sendRedirect("cs2k_GroupCopiedUpdt.jsp") ;        request.setAttribute("GroupId", GroupId);        request.setAttribute("GroupDesc", GroupDesc);        request.setAttribute("vRow", vRow);        request.setAttribute("vRow1", vRow1);        getServletConfig().getServletContext().getRequestDispatcher("/GroupCopiedUpdt.jsp").forward(request, response);    }

Viewing all articles
Browse latest Browse all 675

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>