this is my problem:
i insert a value into the database and forward it another page which displays the result.
since i use jsp:forward, the user browser displays the url from which the jsp:forward was called.
if i refresh the browser, the data are again inserted to the database. is there a way to prevent it.
Discussions
Web tier: servlets, JSP, Web frameworks: problem with jsp:forward when user refreshes the browser
-
problem with jsp:forward when user refreshes the browser (2 messages)
- Posted by: Dhanagopal Sivaraman
- Posted on: December 05 2001 07:55 EST
Threaded Messages (2)
- problem with jsp:forward when user refreshes the browser by joseph yi on December 05 2001 14:52 EST
- problem with jsp:forward when user refreshes the browser by Dhanagopal Sivaraman on December 08 2001 01:53 EST
-
problem with jsp:forward when user refreshes the browser[ Go to top ]
- Posted by: joseph yi
- Posted on: December 05 2001 14:52 EST
- in response to Dhanagopal Sivaraman
i'm sure there are more elegant solutions, but here's one that kind of works:
test.jsp:
<%
if (session.getAttribute("forwarded") != null) {
out.println(session.getAttribute("forwarded"));
} else {
%>
<jsp:forward page="/status.jsp">
<jsp:param name="msg" value="Ok, data inserted. don't hit refresh..." />
</jsp:forward>
<% } %>
status.jsp:
<%= request.getParameter("msg") %>
<%
session.setAttribute("forwarded", "Please do not hit refresh!");
%>
Of course now you're burdened with keeping track of the 'forwarded' attribute of the session object.
-
problem with jsp:forward when user refreshes the browser[ Go to top ]
- Posted by: Dhanagopal Sivaraman
- Posted on: December 08 2001 01:53 EST
- in response to joseph yi
thank u. this one is fine for my application.