java - How can i get a session variable (setted with a servlet) in jstl -
i'm making application jsp , java servlets, problem
need check if session variable set (i set on servlet)
on jsp file. i'm using jstl cheking this, code is:
string siguiente = "/vista2.jsp"; ... if(request.getparameter("user").equals(usdb) && request.getparameter("pass").equals(passdb)){ out.println("coinciden usuario y contraseƱa
"); httpsession hs = request.getsession(true); integer par = (integer)hs.getattribute("vars"); if(par==null){ random rg = new random(); par = new integer(rg.nextint(1000)); hs.setattribute("vars", par); } requestdispatcher dispatcher = getservletcontext().getrequestdispatcher(siguiente); dispatcher.forward(request, response); break; }
and in jsp code i'm trying
<c:choose>
<c:when test="${vars!=null}">
<c:redirect url="/index.jsp" />
</c:when>
<c:otherwise>
<h1>has entrado exitosamente</h1>
</c:otherwise>
</c:choose>
and though access page directly(without accessing servlet before) page doesn't redirect
Comments
Post a Comment