• 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

How to show message in jsp when update a record in database

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello guys.....

please help me out....

I m working on a simple college project of mine.

So, i have created two JSP files, In first Jsp (show.jsp) file i am showing or displaying the records from database (MySQL). In each row i create a button with the help of Bootstrap 4 which is used to edit that row. On click on that button a modal (Bootstrap component) will open and a form i have created in the modal to edit input fields. So that if i submit the form by editing some input fields that it goes to another JSP (edit.jsp) file, in this jsp file i have only java code and SQL query for updating records after this it goes redirect to the first JSP (show.jsp) file and show records again with updation. All things working properly.

So my problem is that if i update any of row then i dont get any msg of update like : your data is updated successfully !
I also add some code for showing msg if i update any row but didnot worked. i just add alert function in second jsp file (edit.jsp) to show message but it doesnot working and it redirect to first jsp file without showing alert msg.

so please provide me that code for showing msg when i update any row.
 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pankaj,

I know this is probably 3 weeks too late for your assignment, but hopefully it will help the next person.

You could capture the result of the SQL update in edit.jsp, and pass a parameter in the URL when you redirect back to show.jsp. For example, the java code in your JSP could be something like:



Then in show.jsp, you would need to check for the presence of a request parameter named "updateResult", and display a message accordingly.

A few general notes about this:
  • it isn't best practice to have a lot of Java code in your JSPs
  • the value of "updateResult" parameter should really be URL encoded before it is added to redirectUrl on line 8
  • depending how you did your redirect in edit.jsp, the part of the HTML page that includes the alert might never be sent to the browser



  • reply
      Bookmark Topic Watch Topic
    • New Topic