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.
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.