This is my structure of the project:- [1]: https://i.sstatic.net/ootY1.png
My problem is that whenever I am running my project on the server, there is an HTTP Status 404 Error. This is the error I am getting by the server:-
The requested resource [/Doctor_Appointment_Application/Regis] is not available
I am using annotations to register my servlets and there is only a welcome file in my web.xml.
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="4.0"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd">
<display-name>User Login</display-name>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>/JSP/login.jsp</welcome-file>
</welcome-file-list>
</web-app>
My Register Servlet:-
package com.servlet;
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 com.bean.RegisBean;
import com.dao.RegisDao;
@WebServlet("/Regis")
public class Regis extends HttpServlet {
private static final long serialVersionUID = 1L;
public Regis() {
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String fullname=request.getParameter("fullname");
String email=request.getParameter("email");
String username=request.getParameter("username");
String password=request.getParameter("password");
long mobile= Long.parseLong(request.getParameter("mobile"));
String address=request.getParameter("address");
String identity=request.getParameter("radio");
String specialisation=request.getParameter("special");
String degree=request.getParameter("degree");
String exp=request.getParameter("exp");
String fees=request.getParameter("fees");
RegisBean regisBean=new RegisBean();
regisBean.setFullname(fullname);
regisBean.setEmail(email);
regisBean.setUsername(username);
regisBean.setPassword(password);
regisBean.setMobile(mobile);
regisBean.setAddress(address);
regisBean.setIdentity(identity);
if(identity.equals("Doctor")) {
regisBean.setSpecialiasation(specialisation);
regisBean.setDegree(degree);
regisBean.setExperience(exp);
regisBean.setFees(fees);
}
RegisDao dao=new RegisDao();
String userRegistered=dao.registerUser(regisBean);
if(userRegistered.equals("SUCCESS"))
request.getRequestDispatcher("/JSP/conf.jsp").forward(request, response);
else {
request.setAttribute("errMessage", userRegistered);
request.getRequestDispatcher("/JSP/register.jsp").forward(request, response);
}
}
}
EDIT 1:
Register.jsp:-
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Registration Page</title>
<style type="text/css">
<%-- <%@include file="/CSS/register.css"%> --%>
<%@include file="/CSS/regis.css"%>
</style>
<script src='https://kit.fontawesome.com/a076d05399.js'></script>
<script>
function validate() {
var password = document.form.password.value;
var confpassword = document.form.confpassword.value;
/* if (password.length < 6) {
alert("Password must be at least 6 characters long.");
return false;
} else */ if (password != confpassword) {
alert("Confirm Password should match with the Password");
return false;
}
}
</script>
</head>
<body>
<form name="form" action="<%=request.getContextPath() %>/Regis" method="post" onsubmit="return validate()">
Full Name: <input type="text" name="fullname" required>
<br>
<br>
Email: <input type="text" name="email" required>
<br>
<br>
Username: <input type="text" name="username" required>
<br>
<br>
Password: <input type="password" name="password" required>
<br>
<br>
Confirm Password: <input type="password" name="confpassword" required>
<br>
<br>
Mobile Number: <input type="number" name="mobile" required>
<br>
<br>
Address: <input type="text" name="address" required>
<br>
<br>
Identity: Doctor <input type="radio" name="radio" value="Doctor" required>
<div class="reveal">
Specialisation: <select name="special" class="require-if-active">
<option selected disabled>Choose...</option>
<option value="Allergist">Allergist</option>
<option value="Anesthesiologist">Anesthesiologist</option>
<option value="Cardiologist">Cardiologist</option>
<option value="Dermatologist">Dermatologist</option>
<option value="Endocrinologist">Endocrinologist</option>
<option value="Gastroenterologist">Gastroenterologist</option>
<option value="Hematologist">Hematologist</option>
<option value="Immunologist">Immunologist</option>
<option value="Internist">Internist</option>
<option value="Neurologist">Neurologist</option>
<option value="Pulmonologist">Pulmonologist</option>
<option value="Oncologist">Oncologist</option>
</select>
<br>
<br>
Degree: <select name="degree" class="require-if-active">
<option selected disabled>Choose...</option>
<option value="MBBS">MBBS</option>
<option value="BDS">BDS</option>
<option value="BAMS">BAMS</option>
<option value="BUMS">BUMS</option>
<option value="BHMS">BHMS</option>
<option value="BYNS">BYNS</option>
<option value="B.V.Sc & AH">B.V.Sc & AH</option>
</select>
<br>
<br>
Experience: <input type="number" name="exp" class="require-if-active">
<br>
<br>
Fees: <input type="number" name="fees" class="require-if-active">
</div>
Patient <input type="radio" name="radio" value="Patient" required>
<span style="color: red"><%=(request.getAttribute("errMessage") == null) ? "" : request.getAttribute("errMessage")%></span>
<br>
<br> <input type="submit" value="Register">
</form>
</body>
</html>
EDIT 2:
I just tried to do an experiment, what I did is I created another jsp file and a servlet to check if the problem is in my jsp and servlet files or not. So the same thing happened, the jsp file ran successfully but the server wasn't abl to find the servlet after submitting the form method.
Any kind of help is appreciated.
Hello to whosoever is seeing this, I solved this query by removing the mysqljdbc.auth.dll from my build path. This solved my problem and it is working fine now. If you are having a problem with the mysqljdbc.auth.dll file, you just have to copy it in the JDK 8 bin folder and it will work fine.