java - Session attribute not reflected in JSP -


so have jsp 1 loads request params session access in second jsp .

my jsp 1 code :

<jsp:usebean id="emails" scope="request" class="java.lang.string" /> <%  string email = emails; session.setattribute( "allemail",email); %>  <p style="display:block" ><%= session.getattribute( "allemail" )%></p> 

my jsp 2 code :

<p style="display:block" ><%= session.getattribute( "allemail" )%></p> 

now can see <p> in first jsp populated data paragraph in second jsp blank

when change session.setattribute( "allemail",email); session.setattribute( "allemail","hello world); can see correct value reflected in both paragraphs .

what doing wrong ?

the servlet populates jsp1 has following request dispatcher

requestdispatcher dispatch = request.getrequestdispatcher("jsp1"); 

i think issue both jsp's initialised @ same time session in second jsp has no value .

as per above scenario. since request hold session object sure.

you can try :-

<p style="display:block" >     <%(string)request.getsession().getattribute("allemails"); %> </p> 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -