First of all, there are certain things you need to understand while developing web applications in Java. I have a few recommendations and inputs
- Please don't use
Scriptlets
. Scriptlets are deprecated and they make your code clumsy and the maintainance will be hard. Use JSTL
- You need to create a
form
in your html
to have a set of variables to push them to the server on clicking submit
button. The form will have an action
attribute which contains the URL
where the request should be sent
- Create a
Servlet
and map with the action URL
and write the doPost
method which can receive the form parameters and do the business logic whatever changing the status from NO
to WAIT
or anything else
- Please take a note that you need to have
Session
variables in order to have the store the data in between requests from the same client. eg browser.
Is making new servlet for this task a good option or doing the code in jsp a better one ?
Writing a new servlet is a good option, than doing the business logic in jsp page. jsp is meant for presentation, just view. They shouldn't be used to perform business logic
If i need to make a new servlet then what will be the code for it on jsp page .?
JSP should just have all the necessary html elements and attributes like form, action attribute etc.. to post the parameters in the request to the action URL. Please note the method attribute of form. You should use HTTP POST method for posting form parameters to the server
Note : Finally, Writing Servlets are also NOT recommended. Instead, you should opt for webframeworks like Spring MVC
, Struts etc. Please go through the link to understand about web frameworks answered by @BaluC
Hope this clarifies.