I’m restricted to work on an enterprise software project using Netbeans IDE, and no frameworks.
The front-end display is register.jsp. My Model package contains Customer.java class, with some getters and setters. A Data package contains ‘CustomerData.java’, with DB functions related to the Customer: registration, log-in, etc. CustomerData extends HttpServlet.
I need to reference a specific method from the CustomerData class from my registration form. Is this possible to do?
If this is possible to do, what should the web.xml file entry be for the servlet and servletmapping?
Here is code.
Register.jsp
<form name="loginForm" method="post" action="CustomerData/RegisterCustomer">
......
</form>
CustomerData.java skeleton:
public class CustomerData extends HttpServlet {
public void registerCustomer(HttpServletRequest request)
throws ServletException, IOException
{
// this is the method I need to reference. It creates a db connection, checks to see if
// the Customer is already in the DB, and if not, registers the user.
}
public void loginCustomer(HTTPServlet request)
throws ServletException, IOException
{
// Some other Customer data method that will need to be called from my login.jsp page
}
public void SomeOtherMethod()
{
// some helper methods or validation methods for Customer
}
}
I would recommend you the below thing.
In the JSP page you can define one parameter say
oprwhere you can set value of the operation.In the Servlet you can handle the operation by the operation value passed as below
Hope this will help you.