I am using Apache tomcat9 server My register.jsp file is properly rendering in the browser by when i am clicking to submit button after adding information in the form control is not getting transfer to servlet at all it shows 404 error onl!!!
**here is Register.jsp file **
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
<link href="Style.css" rel="stylesheet">
</head>
<body>
<form action="register" method="post">
<h2 style="color: black; text-align:center;">System Registration Form</h2><br><br>
<div id=regdiv><br><br>
<table>
<tr><td><label id="lable">Enter name:</label></td><td><input type="text" name="uname" id="text_box" placeholder = " Name"><br><br></td>
<tr><td><label id="lable">Enter email:</label></td><td><input type="email" name="uemail" id="text_box" placeholder = " abc@gmai.com"><br><br></td>
<tr><td><label id="lable">Enter password:</label></td><td><input type="Password" name="upass" id="text_box" placeholder = " *******"> <br><br></td>
<tr><td><label id="lable">Gender:</label></td><td>
<input type="radio" name="gender" value="Male">Male
<input type="radio" name="gender" value="Female">Female
<input type="radio" name="gender" value="Other">Other<br><br></td>
<tr><td><label id="lable">Address: </label></td><td><textarea rows="1" cols="12" name ="add"></textarea><br><br></td>
</table>
<input type="submit" id="sub" value="Register"><br><br>
</div>
<p>Already Registered!!<a href="Login.jsp"> Sign-in </a> instead</p>
<br><br>
</form>
</body>
</html>
**And here is my RegistrationServlet **
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import dbHandler.datainjector;
@WebServlet("/a")
public class registerServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String name = req.getParameter("uname");
String email = req.getParameter("uemail");
String pass = req.getParameter("upass");
String gen = req.getParameter("gender");
String add = req.getParameter("add");
datainjector.addCustomer(name,email,pass,gen,add);
resp.sendRedirect("Login.jsp");
}
}
Here is my web.xml file
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
<display-name>com.shopKart</display-name>
<welcome-file-list>
<welcome-file>Register.jsp</welcome-file>
</welcome-file-list>
</web-app>
What i am expecting I tried many times to connect with my servlet using annotation as you all can see in the code above when ever i press "register" button on the browser the control should transfer to the servlet and hence the class should be called named as Addcustomer. and the information should added in the database in the table named as customer.
Problem The control is not going to servlet even if i am printing ("Hello "+name) in the client machine it is not executing at all only 404 error showing in the machine ----
please help Much appreciated!!