August 31, 2012

How to store session while sendRedirect

Question by Thunderbird

I have a condition where I want to remove the attribute from the session and I am doing response.sendRedirect after that.

But I am not sure if it will remove the session attribute ? Any thoughts ?

P.S. I have to do sendRedirect, I cannot use forward.


ANSWER : Just a little debugging solved my concern. I checked the session attribute value by getting the variable and it was null. So it removed the variable from the session.

Answer by Starx

Yes, if Constants.USER_REQUEST_URI gives the correct name as it is stored in session, then it will remove them.

Session work differently than GET and POST request so redirecting and forwarding will make no difference.

Good way to confirm this, would be to check if the variable is accessible after the redirect


Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+


Please fill the form - I will response as fast as I can!