File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Request Dispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Request Dispatcher" Watch "Request Dispatcher" New topic
Author

Request Dispatcher

Nijeesh Balan
Ranch Hand

Joined: Oct 09, 2000
Posts: 116
Hi,
I'm facing the same age old problem with RequestDispatcher..(i.e) On Refresh, the request is dispatched and the data is getting inserted into the database again
I searched few links .. but none of them gives a satisfying answer..
Is it always better to go for response.sendRedirect when you perform db related operations and then redirect to a jsp.
Or is there any other workaround for this dispatcher problem?
Plz clarify.
Thanks in Advance
Nijeesh.


Thanks & Regards,<br />Nijeesh.
Manohar Karamballi
Ranch Hand

Joined: Jul 17, 2001
Posts: 227
hai..
What i understood is that on every refresh request is dispatched and whatever component handling request is performing logic to insert data to DB. I donn think this is problem with dispatcher as it is doing what it is supposed to do.
I assume following scenarion is the one ur working..
we have screen1 where some data is enetred and submitted and then screen2 is displayed.
Now on refreshing screen2 data will be inserted again.
To getaway this problem perform the logic such that data will be inserted only in the cases u wann..
Suppose there is some registration form is screen1 and u wann to update DB only when submit button is clicked perform following steps..
1) before redirecting to screen2 set one boolean flag like update=true in request depending upon some request paramters from screen1.
2) before updating check for this boolean
like
if(update)
{
//Insert data
}
So flag will remain false and no updation occurs.
Hope this helps..
Rgds
Manohar
Manohar Karamballi
Ranch Hand

Joined: Jul 17, 2001
Posts: 227
hai..
What i understood is that on every refresh request is dispatched and whatever component handling request is performing logic to insert data to DB. I donn think this is problem with dispatcher as it is doing what it is supposed to do.
I assume following scenarion is the one ur working..
we have screen1 where some data is enetred and submitted and then screen2 is displayed.
Now on refreshing screen2 data will be inserted again.
To getaway this problem perform the logic such that data will be inserted only in the cases u wann..
Suppose there is some registration form is screen1 and u wann to update DB only when submit button is clicked perform following steps..
1) before redirecting to screen2 set one boolean flag like update=true in request depending upon some request paramters from screen1.
2) before updating check for this boolean
like
if(update)
{
//Insert data
}
So flag will remain false and no updation occurs.
Hope this helps..
Rgds
Manohar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Request Dispatcher
 
Similar Threads
how to pass control to another page with out using request dispatch
struts 2 validation and prevent double submit
Lost Request Attributes
non-HTTP request or response Exception
Passing Document from servlet to JSP see code