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
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
posted
0
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
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
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