• 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

Using a button to update an SQL database

 
Greenhorn
Posts: 1
  • 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
 
Marshal
Posts: 26537
81
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.
 
rubbery bacon. rubbery tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic