Discussions

Web tier: servlets, JSP, Web frameworks: Return to previous view after user action

  1. Return to previous view after user action (1 messages)

    Hello, Is there a simple way to return a user to the view (jsp etc.) they were on before they called an action (servlet or struts action), which returns without doing anything? I want the browser to go back to the previous URI before the user called the action so nothing changes, i.e. the view doesn't change and they stay on the same page. This seems like it should be an easy thing to do and I'm probably missing something very obvious but a google search hasn't brought up much that I can see useful. Thanks Andy B
  2. Hi Andy B, I saw this question earlier and though you would readily get an answer, but that has not been the case. I will assume that you are talking about returning to the same page after action handling. If that is the case the recipe in Struts is to set the forward to null, as shown in the code snippet below. public ActionForward login (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Perform the needed action // return null will return to or reload the page return null; } Since you mentioned the possibility of other frameworks, you could do the comparison and evaluation with the dWebSpec dictionary site.