Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

parameter value not resetting when hitting browser refresh button

Status
Not open for further replies.

maxpower1

Programmer
Jul 29, 2001
488
US
in the action-mapping, I defined a "USEREVENT" parameter for an action mapping. This parameter is passed through the URL to a DeleteAction class in when a user hit a "Delete" button on my jsp page. Hence, the URL is like this:


The weird thing is, if a user hits the refresh button on the browser AND this refreshes the page, that "USEREVENT" parameter with value "Delete" is being sent again! I don't want this to happen.

Qs:
1. Is there a way to initialize the parameter value to null after the "Delete" button is clicked so when a user hits the
refresh button, the "USEREVENT" parameter is not sent?

thanks






~za~
You can't bring back a dead thread!
 
Hi,

I dont think that is possible as its a requestURL as similar to mutiple submits on refresh.

Otherway around would be,

In the ActionForm define a hidden variable and initilize it to a constant value. Once you have received the method call in the DispatchAction check the value of the variable if that formValue == constantValue then do the necessary action. once the action is done set the formValue to a differentConstant.

Form form = (Form)actionForm;
if(form.get("hidden").toString.equals("NO"))
{
// necessary Action to delete
}
form.set("hidden","YES");
return action;

Try this.. even I try too and find a better solution.

Cheers,
Venu


 
One way to get around with that is to redirect user to another page to display the HTML. Let say your page with the parameter is:


in your inventory.jsp, after it process the business logic for the DELETE event, instead of output HTML within the same request, redirect back to itself without the parameter or different parameter value. i.e. in your inventory.jsp:

<%
String event = request.getParameter(&quot;USEREVENT&quot;);
if (event.equals(&quot;DELETE&quot;)) {
// ... do your busuness
response.sendRedirect(&quot;inventory.jsp&quot;);
return; // stop processing the HTML code
} else {
// ... do your business logic as with no parameter
}
%>

After the redirect, when user hit refresh, it actually refresh it with inventory.jsp but not ivnentory.jsp?USEREVENT=DELETE. However, there is a catch, if user hit back button of the browser, it then go back to ivnentory.jsp?USEREVENT=DELETE.
 
thanks byam. my friend found the solution, in the action class :-

//redirect page i.e. &quot;\ViewInventory.do&quot;
ActionForward forward=new ActionForward(redirectPage);
forward.setRedirect(true);


~za~
You can't bring back a dead thread!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top