aspose file tools*
The moose likes JSP and the fly likes refreshing problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "refreshing problem" Watch "refreshing problem" New topic
Author

refreshing problem

vikasids sharma
Ranch Hand

Joined: Aug 01, 2003
Posts: 157
hi all
i m using JSP for front end .
A controller servlet for controlling the flow of application and beans for inserting a record in database.
I give a message to user after sucessfull insertion of record in database(using alert message of javascript).
Now record is inserted once but message is displayed every time i refresh page which is irritating to user.
Can anybody tell me how to stop displaying message when user presses refresh action of browser.
Thanks in advance
vikas


Thanks
Vikas Sharma
SCJP(1.4)
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Moving to the JSP Forum...
Nischal Tanna
Ranch Hand

Joined: Aug 19, 2003
Posts: 182
Hi i guess this is a common problem with JSPs .but i guess ur data is incomplete for solving.i guess if u provide a code snippet then it can help.anyways or else take a session attribute by using.
String ses=session.getValue("action")
the very first time the value of ses will be null.so take a if loop ..
if((ses==null)||(ses.equals(""))
{
//give the database calling code here..i mean ur application logic
}
else
{
out.println("you have already inserted ur record");
}
i hope this gives u a hint..
regards,
Nischal


Thnx
vikasids sharma
Ranch Hand

Joined: Aug 01, 2003
Posts: 157
thanks but can i have some other alternative to it rather than using Session Object.
Originally posted by Nischal Tanna:
Hi i guess this is a common problem with JSPs .but i guess ur data is incomplete for solving.i guess if u provide a code snippet then it can help.anyways or else take a session attribute by using.
String ses=session.getValue("action")
the very first time the value of ses will be null.so take a if loop ..
if((ses==null)||(ses.equals(""))
{
//give the database calling code here..i mean ur application logic
}
else
{
out.println("you have already inserted ur record");
}
i hope this gives u a hint..
regards,
Nischal
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

There are some patterns solving this related to the MVC architecture, but the easiest way is to execute a response.sendReirect() to a confirmation page after the data has been posted.
This should be done using a Controlling Servlet and managing the Views in the JSPs and works the same way as the example here
Dave
bharat nagpal
Ranch Hand

Joined: Oct 26, 2002
Posts: 76
when you insert the value in the database, simply set one boolean variable to true. then you can make that boolean value available in JSP page, and if you don't want to use session object you can use request object for this. while callling Javascript method, you can pass this value to that method from within JSP page.(in <%%>
hth
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: refreshing problem