request.getSession() session data to be retained upon redirection -how?

  • Thread starter phillip.s.powell
  • Start date
P

phillip.s.powell

What is the best form of redirection to ensure that
request.getSession() data is not lost?

<code>
<pre>
// DO STUFF AND RETAIN IN request.getSession() in index.jsp
response.sendRedirect(forwardUrl);
</pre>
</code>

The moment you go to "forwardUrl":

<code>
<pre>
out.println(request.getSession().toString()); // YOU SEE A BRAND NEW
request OBJECT WITH NO SESSION DATA
</pre>
</code>

How do I prevent this? Is &lt;jsp:forward page="<%= forwardUrl %>" /
&gt; the best option or do you recommend another method?

Phil
 
D

Dave Miller

What is the best form of redirection to ensure that
request.getSession() data is not lost?

<code>
<pre>
// DO STUFF AND RETAIN IN request.getSession() in index.jsp
response.sendRedirect(forwardUrl);
</pre>
</code>

The moment you go to "forwardUrl":

<code>
<pre>
out.println(request.getSession().toString()); // YOU SEE A BRAND NEW
request OBJECT WITH NO SESSION DATA
</pre>
</code>

How do I prevent this? Is &lt;jsp:forward page="<%= forwardUrl %>" /
&gt; the best option or do you recommend another method?

Phil
Depending on what you're forwarding to, you might try
RequestDispatcher or jsp:include
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top