英文:
Status 500 error instantiating servlet class in Tomcat
问题
I was executing a web project and it is throwing an error 500 error instatiating servlet class .
我正在执行一个Web项目,但它抛出了一个错误500错误,实例化Servlet类。
I am using tomcat 9.0.71 and using web module 4.0 .
我使用的是Tomcat 9.0.71,并且使用Web模块4.0。
This is the error message on the screen.
这是屏幕上的错误消息。
This is the error page status 500
This is the html document
这是HTML文档
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>This is a hello world</h1>
<br>
<form action="hello" method="get">
<input type="submit">click to say hello world
</form>
</body>
</html>
This is the servlet class
这是Servlet类
package ronit;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.*;
@WebServlet("/hello")
class hello extends HttpServlet{
static final long serialVersionUID = 35335L;
public void doGet(HttpServletRequest req, HttpServletResponse res) {
try {
PrintWriter p = res.getWriter();
p.println("Hello World");
}catch(IOException e) {e.printStackTrace();}
}}
This is the deployment configuration in the server
这是服务器中的部署配置
This is the console after execution
This is the project explorer view
I am using annotations instead of web.xml and deploying the file by right clicking on the project and run on server .
我使用注解而不是web.xml,并通过右键单击项目并在服务器上运行来部署文件。
Please consider telling me if more details required on question
如果需要更多细节,请告诉我。
英文:
I was executing a web project and it is throwing an error 500 error instatiating servlet class .
I am using tomcat 9.0.71 and using web module 4.0 .
This is the error message on the screen.
This is the error page status 500
This is the html document
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>This is a hello world</h1>
<br>
<form action ="hello" method="get">
<input type="submit">click to say hello world
</form>
</body>
</html>
This is the servlet class
package ronit;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.*;
@WebServlet("/hello")
class hello extends HttpServlet{
static final long serialVersionUID = 35335L;
public void doGet(HttpServletRequest req, HttpServletResponse res) {
try {
PrintWriter p = res.getWriter();
p.println("Hello World");
}catch(IOException e) {e.printStackTrace();}
}}
This is the deployment configuration in the server
This is the console after execution
This is the project explorer view
I am using annotations instead of web.xml and deploying the file by right clicking on the project and run on server .
Please consider telling me if more details required on question
答案1
得分: 0
Your servlet class has no public, zero argument, constructor. It needs one, otherwise Tomcat can not instantiate it--exactly as the error output is telling you.
英文:
Your servlet class has no public, zero argument, constructor. It needs one, otherwise Tomcat can not instantiate it--exactly as the error output is telling you.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论