Package servlet
Class SignupServlet
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
servlet.SignupServlet
- All Implemented Interfaces:
Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
@WebServlet("/signup")
public class SignupServlet
extends javax.servlet.http.HttpServlet
Servlet that handles new customer registration and signup process.
Creates customer accounts with password hashing.
Validates input data and checks for existing email addresses.
- Author:
- TAMIL MUGHILAN
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
doGet
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Handles GET requests by redirecting to signup page.protected void
doPost
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Handles POST requests for customer registration.void
init()
Initializes the servlet with database storage and customer service.Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Field Details
-
dataStorage
-
customerService
-
-
Constructor Details
-
SignupServlet
public SignupServlet()
-
-
Method Details
-
init
public void init() throws javax.servlet.ServletExceptionInitializes the servlet with database storage and customer service.- Overrides:
init
in classjavax.servlet.GenericServlet
- Throws:
javax.servlet.ServletException
- if initialization fails
-
doGet
protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException Handles GET requests by redirecting to signup page. Redirects already logged in users to their appropriate dashboard.- Overrides:
doGet
in classjavax.servlet.http.HttpServlet
- Parameters:
request
- the HTTP servlet requestresponse
- the HTTP servlet response- Throws:
javax.servlet.ServletException
- if a servlet error occursIOException
- if an I/O error occurs
-
doPost
protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException Handles POST requests for customer registration. Validates input, creates customer account, and logs them in automatically.- Overrides:
doPost
in classjavax.servlet.http.HttpServlet
- Parameters:
request
- the HTTP servlet request containing signup form dataresponse
- the HTTP servlet response- Throws:
javax.servlet.ServletException
- if a servlet error occursIOException
- if an I/O error occurs
-