hibernate - Unable to sendRedirect() to a jsp page. IllegalStateException -


im doing sample hibernate web app. , table entries added database im unable redirect response success page.

here code in servlet

httpsession session = request.getsession(true);         try {             userdao userdao = new userdao();             userdao.adduserdetails(username, password, email, phone, city);             response.sendredirect("success");             return; 

my dao code follows

session session = factory.opensession();          transaction tr = session.begintransaction();         user user = new user();           user.setusername(username);  user.setpassword1(password);             user.setemail(email);             user.setcity(city);             user.setphone(phone);             session.save(user);             tr.commit();         system.out.println("\n\n details added \n"); 

im getting syso "details added" in console, not able redirect success.jsp. please im unable see response written http

based in information provide response committed when call sendredirect method, if check documentation method httpservletresponse#sendredirect indicates reason why exception:

llegalstateexception - if response committed or if partial url given , cannot converted valid url

what means modify response before call sendredirect method, common way modify response through printwriter response.getwriter().println, check code not modify response before calling sendredirect method.


Popular posts from this blog