Home > Back-end >  A simple introduction to the servlet case why can't access?
A simple introduction to the servlet case why can't access?

Time:10-19

An error is as follows:

The project structure is as follows:

HelloServlet. Java
 package com. Zixue. Servlet. 

import java.io.IOException;

The import javax.mail. Servlet. Servlet.
The import javax.mail. Servlet. ServletConfig;
import javax.servlet.ServletException;
The import javax.mail. Servlet. ServletRequest;
The import javax.mail. Servlet. ServletResponse;

/* *
* @ the ClassName: HelloServletDemo1
* @ Description: introduction to the servlet program
* @ author: sadfoo2019
* @ date: March 2, 2020 morning 1:54:10
* @ Copyright:
*/
Public class HelloServlet implements the Servlet {

@ Override
Public void destroy () {

}

@ Override
Public ServletConfig getServletConfig () {
return null;
}

@ Override
Public String getServletInfo () {
return null;
}

@ Override
Public void init (ServletConfig arg0) throws ServletException {

}

/* *
* used to handle the customer's request and response to the request of method
*/
@ Override
Public void service (ServletRequest request, ServletResponse response) throws ServletException, IOException {
//to the page output a hellServlet string
The response. GetWriter (). Print (" Hello Servlet... ");
}

}

Web.xml
 
<? The XML version="1.0" encoding="utf-8"?>
XMLNS="http://java.sun.com/xml/ns/javaee"
Xsi: schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
Id="WebApp_ID" version="2.5" & gt;
Test_TomcatServers & lt;/display - name>

Index. Html
Index. Htm
Index. Jsp
Default. Html
Default. Htm
Default. Jsp



HelloServlet

Com. Zixue. Servlet. HelloServlet



HelloServlet
/aaa


CodePudding user response:

Copy your code, no problem, can run, you can copy code into another bag to try,

CodePudding user response:

The
refer to the original poster Cheng Guo response:
an error is as follows:


Program is no problem, see if the project has joined the tomcat server, if not, you can add it, run to see again,

CodePudding user response:

Thank you, have been solved,
  • Related