Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Data re-added when user clicks refresh

 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
User enters data in jsp A which sends it to servlet B which sends the new data along with the old data (kind of like updating a datagrid) to jsp C to display the data. Now everything is okay but if the user presses refresh a message saying "will need to resend data press ok to continue" or something like that is shown in the browser and a new record is added to the DB how can i handle the refresh issue. From what i understand is the servlet called the page using getrequestdispatcher and forwards the page so the url stays the same as that of jspA rite ???. Should i use sendredirect here will that solve the problem if so what abt the attributes of the response object servlet sends to jsp C they will be erased in case of sendredirect and i dont want to add them to session. Any suggestions ??
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read this article and pay special attention to the PRG pattern.
 
Rajesh Khan
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess i am already (sort of ) using this pattern but i do have a question at the end. Let me just re-explain my scenario - User fills a form in JSP Page A the form posts the data to servlet B. The servlet B processes the data and forwards it to a JSP page B. The Pattern however suggests that Servlet B should redirect and not forward to page B. To avoid the "how do i disable refresh" issue. This mechanism will work well for me , however the only thing is servletB adds a couple of attributes before it forwards the request object to page C and if i redirect directly from servlet B to page C I wont have those attribute available. The pattern also suggests that I introduce a page controller (servlet) the purpose of which i didnt really get. But currently the order followed in my code is



With the pageController its going to be as follows (here is the question)
PageA(posts)->PageControllerServlet(Q.What would this do?Will this process the received data from the jsp page)(Redirects)->ServletB(forwards)->PageC
 
If you two don't stop this rough-housing somebody is going to end up crying. Sit down and read this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic