aspose file tools*
The moose likes Struts and the fly likes page refresh adds a new page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "page refresh adds a new page" Watch "page refresh adds a new page" New topic
Author

page refresh adds a new page

Poorav Chaudhari
Ranch Hand

Joined: Sep 17, 2002
Posts: 50
Hi folks,
i am having a design issue with my web application. I am using the struts framework for the application.
the problem i am having is as follows. I have a page1.jsp in which the user can enter info. in a form. when he clicks on submit, the information is uploaded into the database and the user is taken to page2.jsp where he can view a readonly format of the information that he just entered. Now if he presses refresh, the data is re-entered into the database. I know what the problem is (sort of) but i am looking for the correct way to handle this kind of situation.
the following is a psuedo flow of what is going on.
page1.jsp --> createRec.do -->(mapped in struts-config.xml to) --> createRecordAction --> RecordBizObj (does the validation and calls the data access object to create record) --> comes back successfully to createRecordAction --> forwarded to page2.jsp .
pressing refresh recalls the createRec.do and the whole enchillada starts again. how can or should i tackle this problem.
Please help. eagerly awaiting your response. Thank you.


Poorav Chaudhari
Bernardus Irmanto
Greenhorn

Joined: Oct 03, 2003
Posts: 23
Hi there,
when you clicks the refresh button in jsp 2, what do you want to achieve?
since you said that all fields are read only(user wont be able to chnage the data), I assume that there will be no data to be updated. am I right?.
well. If you still want to "re-enter" the data to the database(updating the available record, since you have already had the record when you click submit in jsp1), you could specify other method in the same action (as used by jsp 1) , by adding a specific flag. In the execute method of your action class, you can detect the existence of the flag, and delegate the request to specific method.

rgds
beN
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: page refresh adds a new page