1

I have scenario like login page where when the user access any privileged page, it should redirect to login page and after login it should get redirected back to the original page. I can pass the original page as query parameter. However how can redirect to the original page from the LoginAction class?

Rejeev Divakaran
  • 4,384
  • 7
  • 36
  • 36

1 Answers1

2

Either use response.sendRedirect() and return null from your action, or return an instance of ActionRedirect from your action.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • Can I return an instance ActionRedirct from the execute method of the Action class? The return type of the execute is 'String' isn't it? – Rejeev Divakaran Jan 20 '12 at 08:09
  • Are you using Struts2? I thought you were using Struts1. See http://stackoverflow.com/questions/173846/struts2-how-to-do-dynamic-url-redirects for Struts2 – JB Nizet Jan 20 '12 at 08:11