I am new to JAVA development.
I have created a simple Servlet called 'test'.
package com.MyServlets;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/test")
public class test extends HttpServlet {
private static final long serialVersionUID = 1L;
public test() {
super();
// TODO Auto-generated constructor stub
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter pw= response.getWriter();
pw.println("<h1>This is get request.</h1>");
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter pw= response.getWriter();
pw.println("<h1>This is post request.</h1>");
}
}
its works in Eclipse with Apache Tomcat. But after deployment on Apache Tomcat, it gives the error " error instantiating servlet class".
Version is Tomcat 9.0.54 on both server and eclipse PC.
The operating system Win 10 and also tired on win server 2016.
At First time when I run Servlet, it gives an error Error instantiating servlet class [com.MyServlets.test]
here I have uploaded a full error screenshot
enter link description here
And When I try to access the same servlet second time I get this The origin server did not find a current representation for the target resource or is not willing to disclose that one exists
. Here I have uploaded a full error screenshot enter link description here
My other JSP page works properly on the same Apache Tomcat.
I tried enter link description here It still has not worked