Given two jsp's: myFirstJsp.jsp
, mySecondJsp.jsp
myFirstJsp.jsp
receives the submit parameters from another form, stores some values in the DB, and if everything is successful makes a forward to mySecondJsp.jsp
, sending a couple of parameters like this:
<jsp:forward page="mySecondJsp.jsp">
<jsp:param name="param1" value='<%=request.getParameter("param1")%>'/>
<jsp:param name="param2" value='<%=request.getParameter("param2")%>'/>
</jsp:forward>
Everything works fine, but if the user press F5 or refresh the page, an exception will occur, since the URL would still be pointing to "myFirstJsp.jsp", so basically a duplicate insert exception will occur, and I want to prevent this.
The other option available is to use sendRedirect
instead of forward, like this:
response.sendRedirect( "mySecondJsp.jsp?param1=somevalue¶m2=somevalue" );
however, in this case the parameters will be visible to the user, and although normally they won't change them, I need to prevent that scenario too.
Is there any way to avoid either situations?