java - HttpSession variable null after being set in the Servlet -
here's environment. windows 7, tomcat 8.x , java 7.x i'm writing application, has entry point in servlet, opposed jsp. in servlet create session, assign variable it, , redirect user jsp page. here's java code:
httpsession session = request.getsession(); logger.debug("session id: "+session.getid()+ "new session? "+session.isnew()+ "created: "+new java.util.date(session.getcreationtime())); session.setattribute("implementation", simplementation); session.setattribute("requestid", srequestid); response.reset(); response.sendredirect(request.getcontextpath()+"/jsp/productselection.jsp");
in jsp page redirected try retrieve session attribute set in servlet , value comes null, first time use jsp page. if call again resubmitting url in browser works. :o :( here's relevant jsp code, value of simplementation null first time jsp hit.
<% system.out.println("session id: "+session.getid()+ "new session? "+session.isnew()+ "created: "+new java.util.date(session.getcreationtime())); string simplementation = (string)session.getattribute("implementation"); %>
also if make entry point system jsp page nothing redirect user servlet works expected. session created in servlet not valid until. when jsp page hit. :(
lastly tried using dispatcher.forward instead of response.sendredirect , session variable there, however, bootstrap framework i'm using render pages not render @ all. :( tried in both internet exploder 11.x , chromium 33.x
so question whether behavior i'm seeing normal , expected or if there's wrong here , there's solution out there somewhere? :)
thanks in advance, , let me know if unclear or needs more code.
if im not wrong (i might), should redirect jsp using
request.getrequestdispatcher("productselection.jsp").forward(request, response);
this way same request , able session. way if creating sessions on own should disable default session made jsp's
<%@ page session=“false”%>
make me know if worked. :·)
Comments
Post a Comment