Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

How to display a confirmation message after checking values in the servlet?  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good afternoon people! When I click the Change button, I check to see if the data in the database remains the same. How do I return a confirmation window if the results are not the same?

Example: I select the material I want to change, fill in the inputs, but before clicking Change, I leave the table for some reason, and another user on another computer changes this same material. When I go back and click Change, does the data check, how do I show a message stating that the data has changed and asking if I still want to change it?
 
author
Sheriff
Posts: 23569
138
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Well, servlet *and* database are server side technologies. And terms like "clicking button" and "displaying message" refers to the client side. So, what client side technology are you using? Applets? JavaScript? Flash? ... This may even help us move this topic to the correct forum.

And welcome to the ranch.

Henry
 
Diego Nobre
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Henry Wong wrote:
Well, servlet *and* database are server side technologies. And terms like "clicking button" and "displaying message" refers to the client side. So, what client side technology are you using? Applets? JavaScript? Flash? ... This may even help us move this topic to the correct forum.

And welcome to the ranch.

Henry




I am using jsp and servlets ...

Thank you
 
Author and ninkuma
Marshal
Posts: 66784
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That doesn't really answer Henry's question. Are you using JavaScript to instrument the button in question? Or is the button causing a form to be submitted to a servlet? Or something else? We need more details than you have provided.

Generally, information (including messages) are conveyed from a servlet to a JSP by adding the data to scoped variables (aka "attributes") and forwarding to the JSP. But whether that's the appropriate course of action in this case is not yet clear.
 
Bartender
Posts: 1844
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The server side does not really change much.
It needs to detect the database concurrency issue, and inform the JSP appropriately.
I presume you have handled that side of things.

Well there are two basic options on the client side:
Option #1: Click button - send HTTP Post request via submitting a form.
- sends request, replaces current page with response.  You would need to repopulate the page as it was when submitted, and add an "error" note to the page.

Option #2: Click button - send AJAX request via javascript
- sends request, gets response into javascript variable via a callback.  You can then have javascript code execute based on the result.  Your result could be a JSON object which could either return "success" or an "error message" and then you write code to handle those cases appropriately.   However the page remains as it was when you clicked the button as the response went to javascript rather than replace the current page. 

Either works.
Using AJAX and making "single page applications" is the current trend as I understand it.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!