How to save current url in session in java? And if from my servlet i want to redirect request to this url, how to do this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Step 1: Find out the current URL – use HttpServletRequest.getRequestURI (or getRequestURL, depending on exactly what you need)
Step 2: Add it to the session: use HttpSession.setAttribute
Later
Step 3: Get it out of session:
HttpSession.getAttributeStep 4: Redirect to that URL HttpServletResponse.sendRedirect