[Opensource] redirect after post

fangjm fzxfjl at public.cz.js.cn
Thu Mar 6 20:24:16 PST 2003


Hi,larry hamel

    I also encountered the exact same problem last week in out project development. 
I try to find solution by make modification to transition() method from State 
class, but finally I give up. 

    I searched all code in our current project, and make modification as follows:
  
    original code:
----------------------------------------------------------------------------------
			req.setParameter("page",getParameter("retPage"));
			transition("List", req, res);
			return;
----------------------------------------------------------------------------------
    current code:
----------------------------------------------------------------------------------
			AppTransition userList = UserDBMaint.getListTransition();
			userList.addParam("page",req.getParameter("retPage"));
			userList.addInto(res, req);
			AppController.setRedirectJsp(req, res, userList);
			return;
----------------------------------------------------------------------------------
    where getListTransition is a static factory method creating Transition object, and 
setRedirectJsp method as follows:
----------------------------------------------------------------------------------
	public static void setRedirectJsp(
		ControllerRequest request,
		ControllerResponse response,
		Transition t)
		throws ControllerException {
		ServletControllerRequest sr = (ServletControllerRequest) request;
		HttpServletRequest hreq = (HttpServletRequest) sr.getServletRequest();
		response.add(t);
		String url = t.getTheUrl(true);
		hreq.setAttribute("destination", ConfigManager.getContextPath() + url);
	}
----------------------------------------------------------------------------------
   We use this redirect.jsp in config xml file:

----------------------------------------------------------------------------------
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page language="java" errorPage="/expresso/error.jsp" %>

<%
    String destination = (String) request.getAttribute("destination");
%>

<html>
<head>

<%-- we use the refresh metatag because we need to plant a cookie
	after successful login; otherwise, we'd do a more simple 301 
	redirection code --%>
<META http-equiv="refresh" content="0; url=<%=destination%>">

</head>
<body>
..<br><br>
<a href=<%=destination%>>...</a>
</body>
</html>
----------------------------------------------------------------------------------
    Hope this message help clarify this problem and soon someone find a better solution£¡	

======= £º=======

>Hi,
>
>A user recently complained that there were multiple copies of his entry into a form page, and it turned out to be that the user was refreshing the page and resubmitting the data.
>
>This link talks about redirecting the page that is returned to user after a post so that the URL is reset.  Does anybody else use this?  I think I'm going to try it.
>
>Larry
>
>http://theflangynews.editthispage.com/stories/storyReader$1118
>
>_______________________________________________
>Opensource mailing list
>Opensource at jcorporate.com
>http://mail.jcorporate.com/mailman/listinfo/opensource
>Archives: http://mail.jcorporate.com/pipermail/opensource/

= = = = = = = = = = = = = = = = = = = =
			

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÖÂ
Àñ£¡
 
				 
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡fangjm
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡fzxfjl at public.cz.js.cn
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡2003-03-07






More information about the Opensource mailing list