Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help??  RSS feed

 
Kumaran Sowrirajan
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends
i need one help..plz be platient to read this and give me some solution for my problem.
i am having one combo box and one button called Add.
Combobox is filled with the data coming from the database.if you click the combo data and then press the Add button then the same jsp page is refreshed and it will create one HTML table row below the Add button with the selected values and the corresponding datas from the database.
suppose if the user clicks the Add button after selecting the Combo value for 5 times that much time [that is 5 times in this case] the same page get refreshed and it will create 5 HTML table rows under the Add button.
what i did is if the user select the combo value and click the add button,i placed the selected data and the corresponding data in the session and put it the HTML table row.
Problem what i am facing is.....
if i click the refresh button in the browser or F5 or Control-R in IE or in Netscape browser then the last data which i recently added is added automatically but i want to add the data whenever i click the Add button.
what i want is if i click the refresh button in the browser i want to check whether the data is added previously if so,then the data is not added in the HTML table row otherwise it will create one HTML table row below the Add button.
i want to know how to avoid the data which is keep on adding whenever i click the refresh button.
plz give me one solution....friends
Thanks and Regards
Kumaran.S
 
dagmar timler
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are placing an object into the session before you add it to the table, why don't you create some sort of boolean flag too that could be used to see if the data has already been added.
appologies if this answer is too simple
 
Andrew Cunningham
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is the data from the "Add" action is still in the request object, so when you refresh, the same request object is resent.
One (slightly) dodgey way to do it is to forward the user from the Add page to another JSP page with just a single line of code with a response.forward in it when redirects back to the Add page. The response.forward redirects the user but clears the request object of data. response.redirect redirects the user, keeping any data in the request object.
 
Andrew Cunningham
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh, by the way, if you put more information into your subject line, it makes it easier for people to know what the question is about, and more likely to get responses!
Cheers,
Andrew.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!