Error instantiating servlet class

This is my index.html

<form action="submitForm" method="get"> <input type="submit" name="Submit" value="submit" onclick="" /> </form>

This is my web.xml

`<servlet>
<servlet-name>submitForm</servlet-name>
<servlet-class>student.StudentSurveyFormSubmit</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>submitForm</servlet-name>
<url-pattern>/submitForm</url-pattern>
</servlet-mapping>`

And my servlet class

package student; @WebServlet("/StudentSurveyFormSubmit") public class StudentSurveyFormSubmit extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<h1>" + "Hi, "+request.getParameter("firstName") +" I am here" + "</h1>"); }}

Whenever I deploy my war file and click sumbot button I get an exception as :

The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Error instantiating servlet class student.StudentSurveyFormSubmit org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) java.lang.Thread.run(Unknown Source)

Where am I going wrong?


如果使用web.xml定义servlet,那么删除@WebServlet注释,因为现在您有2个不同的映射。

链接地址: http://www.djcxy.com/p/46236.html

上一篇: Ajax调用contentType:'application / json'不起作用

下一篇: 实例化servlet类时出错