Question: HTTP Status 500 - Servlet execution threw an exception. I am getting this error while calling a java class in servlet. Here is the error.

HTTP Status 500 - Servlet execution threw an exception. I am getting this error while calling a java class in servlet.

Here is the error.

Type Exception Report

Message Servlet execution threw an exception

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

javax.servlet.ServletException: Servlet execution threw an exception org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 

Root Cause

java.lang.StackOverflowError java.base/java.util.Properties.hashCode(Properties.java:1436) java.base/java.util.concurrent.ConcurrentHashMap.hashCode(ConcurrentHashMap.java:1302) java.base/java.util.Properties.hashCode(Properties.java:1436) java.base/java.util.concurrent.ConcurrentHashMap.hashCode(ConcurrentHashMap.java:1302) java.base/java.util.Properties.hashCode(Properties.java:1436) java.base/java.util.concurrent.ConcurrentHashMap.hashCode(ConcurrentHashMap.java:1302) java.base/java.util.Properties.hashCode(Properties.java:1436) java.base/java.util.concurrent.ConcurrentHashMap.hashCode(ConcurrentHashMap.java:1302) java.base/java.util.Properties.hashCode(Properties.java:1436) java.base/java.util.concurrent.ConcurrentHashMap.hashCode(ConcurrentHashMap.java:1302) java.base/java.util.Properties.hashCode(Properties.java:1436) java.base/java.util.concurrent.ConcurrentHashMap.hashCode(ConcurrentHashMap.java:1302) java.base/java.util.Properties.hashCode(Properties.java:1436) java.base/java.util.concurrent.ConcurrentHashMap.hashCode(ConcurrentHashMap.java:1302) java.base/java.util.Properties.hashCode(Properties.java:1436) java.base/java.util.concurrent.ConcurrentHashMap.hashCode(ConcurrentHashMap.java:1302) java.base/java.util.Properties.hashCode(Properties.java:1436) java.base/java.util.concurrent.ConcurrentHashMap.hashCode(ConcurrentHashMap.java:1302) java.base/java.util.Properties.hashCode(Properties.java:1436) java.base/java.util.concurrent.ConcurrentHashMap.hashCode(ConcurrentHashMap.java:1302) java.base/java.util.Properties.hashCode(Properties.java:1436)

Here is a code of my java class

@WebServlet("/register")

public class Customers extends HttpServlet{

private static final long serialVersionUID = 1L;

CustomerInfo customerInfo;

public void init() {

customerInfo = new CustomerInfo();

}

public Customers() {

super();

}

//get info from the user

protected void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

response.getWriter().append("Served at: ")

.append(request.getContextPath());

RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/register.jsp");

dispatcher.forward(request, response);

}

protected void doPost(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

String firstName = request.getParameter("firstName");

String lastName = request.getParameter("lastName");

String phoneNumber = request.getParameter("phoneNumber");

CustomerPOJO customerPOJO = new CustomerPOJO();

customerPOJO.setFirstName(firstName);

customerPOJO.setLastName(lastName);

customerPOJO.setPhoneNumber(phoneNumber);

try {

//send email

customerInfo.registerEmployee(customerPOJO);

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/details.jsp");

dispatcher.forward(request, response);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!