jsp - java.lang.illegal state exception -
if (request.getparameter("print_type") != null) { string print_type = request.getparameter("print_type").tostring(); if (print_type.contains("1"))//preprinted page { session.removeattribute("default_selected_opd_ticket"); session.setattribute("default_selected_opd_ticket", "1"); if (session.getattribute("opdticket_preprinted") != null) { printpg = session.getattribute("opdticket_preprinted").tostring(); } else if (print_type.contains("3"))//preprinted page { session.removeattribute("default_selected_opd_ticket"); session.setattribute("default_selected_opd_ticket", "3"); printpg = "../opdreport/antenatal_report.jsp"; } } else { //for blank page session.removeattribute("default_selected_opd_ticket"); session.setattribute("default_selected_opd_ticket", "2"); if (session.getattribute("opdticket_blank") != null) { printpg = session.getattribute("opdticket_blank").tostring(); } else { printpg = "../opdreport/opdticket_blank.jsp"; } } // printpg = "../opdreport/opdticket_blank.jsp";//this jsp request.getsession().setattribute("backpage", backpg); request.getsession().setattribute("printpage", printpg); request.getsession().setattribute("regno", registration.getregistrationno()); request.getsession().setattribute("pid", registration.getpatientid()); registration = null; if (request.getparameter("selectedoption") != null) { string strselectedoption = request.getparameter("selectedoption").tostring(); if (strselectedoption.equals("withoutnk")) { response.sendredirect("../opdreport/printframe.jsp"); return; } else if (strselectedoption.equals("withnk")) { response.sendredirect("../opdregistration/nk1details.jsp"); return; } } }
above part of code given. here not able redirect mentioned jsp page.
all datas getting saved without redirecting page giving illegal state exception error. here using 3 radio buttons value 1,2,3 respectively.
the user select radio button according requirement & according redirect respective page.
in probability, you've written response stream before doing sendredirect()
. illegalstateexception
thrown if try redirect after flushing output stream or writing cookie or header etc.
Comments
Post a Comment