• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Display Message when I insert or update record

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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]
 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dev,
Yes your code does what you need. What is your query ?
 
Dev Anand
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

No you cannot. Javascript executes at client side and servlet executes at server end. Why cant throw a confirmation page instead of javascript alert.
 
reply
    Bookmark Topic Watch Topic
  • New Topic