aspose file tools*
The moose likes Servlets and the fly likes Display Message when I insert or update record Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Display Message when I insert or update record" Watch "Display Message when I insert or update record" New topic
Author

Display Message when I insert or update record

Dev Anand
Ranch Hand

Joined: Aug 30, 2009
Posts: 41
I have a form in Jsp. When I click 'submit', it goes to one Servlet page to do insert or update operations.
Now, I want to display a message when I insert or update record. When I press the Ok button of the message then, the application should be redirected to the home page.

//---------------------code Start-----------------


//-------------------------EndCode----------

[Edit:added code tags]
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


Dev,
Yes your code does what you need. What is your query ?
Dev Anand
Ranch Hand

Joined: Aug 30, 2009
Posts: 41
Balu,
When I execute that code, I'm not getting the Javascript message. The application is directed to the given page.

With Regards
Dev Anand. P
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9302
    
  17

What you are trying to do is display an alert message and dispatch the request to a page at the same time. This is not possible in the way you want. You'll have to set a request attribute of the success/error message and then the page to which you redirect the request (AdminHome.jsp/AddRegion.jsp) should check if there is a success of failure message and display an alert message or simple message on top of the page. So basically you'll have to show the message on the JSP page. Right now you might get an alert message if update of a record fails (I used might as there are not <html> or <head> tag in the code that you send to the client so browser might not be able to parse it). The alert on successful update of record is commented and if you uncomment it, then you might face an IllegalStateException on the request dispatcher step...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


No you cannot. Javascript executes at client side and servlet executes at server end. Why cant throw a confirmation page instead of javascript alert.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Display Message when I insert or update record