Reference book "JSP Web Development Case Tutorial"
Under the src file in the JSP project, create Helloservlettest.java, code as follows, note the package name of SRC, my package name is zhbit.com
Package zhbit.com;
Import Java.io.ioexception;import Java.io.printwriter;import Javax.servlet.servletexception;import Javax.servlet.http.httpservlet;import Javax.servlet.http.httpservletrequest;import Javax.servlet.http.httpservletresponse;public class Helloservlettest extends HttpServlet {public void doget ( HttpServletRequest request, HttpServletResponse response) throws Servletexception, ioexception{ Response.setcontenttype ("Text/html;charset=utf-8"); PrintWriter out = Response.getwriter (); Out.println ("
Modify Web. xml file, Web. XML location, Web. XML modify content, such as
Then open IE, enter in the Address bar: http://localhost:8080/TestJsp/HelloServletTest
The Servlet Foundation recognizes the use