Hello,
You need to use spring mvc to achieve this. The steps for this are:
- Write a java bean representing the data you want to display on the web page.
- Write a DAO to manage the CRUD operations. The finder's in this DAO will return the bean instance or bean instance(s) via a list.
- Write a java class derived from AbstractFormController override processFormSubmission, showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) and referenceData(HttpServletRequest request, Object command, Errors errors) throws Exception. YThe first method in your bean is used to procss the form submissions. The second is typically used to populate the bean instance and the last method is used to populate a map with additional data that may not be part of the form bean.
- Write the xxxx-servlet.xml file containing the mvc mapping of controller against the action. Here specify the command class as the full name of the bean you have created in strp 1. Also supply a value to commandName parameter. This name will be used in JSP page to access the methods of the bean.
- Create a JSP and use spring's form tag library to bind the data to form elements. You can also use JSTL here but I suggest to use the former.
SO if your commadName is say model and the bean has a getter method named say getDescription then you can access this method in JSTL using
Code:
<c:out value="${model.description}"/>
.
Hope this solves your problem. I will also recommend to vist the http://www.springbyexample.org/ site to see some good examples.
Regards,
Prasad P. Khandekar