File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Request Dispatcher

 
Nijeesh Balan
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Manohar Karamballi
Ranch Hand
Posts: 227
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 227
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic