• 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 ...
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Using a button to update an SQL database

Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am just learning how to write jsp pages to create a java web app. I have created a page that displays data from a DB in a table. One of the columns displays a number. I want to add a button next to this number which when clicked will increment the value in the DB by one.

Is there a simple way to implement this? I know I can't call a java method directly from the HTML button. I am displaying the data from the database as below,

The section for hcp reduction will have a + button and a reset button. The + button should add 1 to the value in the DB and the reset will return the value back to 0.

Many thanks
Posts: 26771
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch!

No, there isn't a simple way to update a database from a JSP. That isn't to say that it can't be done, it's just that it shouldn't be done. You can put any old Java code in a JSP (if you do it right) but you shouldn't do that.

The purpose of a JSP is to format data to be output as HTML (usually) for display in a browser. If you want to do other things, like updating databases or deciding which kind of output should be sent to the browser, that's a job for a servlet.

You should already have heard about servlets in the course you're doing, no? I see you're using JSTL in your JSP so your course can't be too far out of date.
Evil is afoot. But this tiny ad is just an ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic