Objective
The previous article introduced a lot of conceptual things, a variety of Baidu Google to put together a Hello Javaweb project, and what is the relationship, as long as the study every day will be exposed to new concepts of things, although to do is, the concept is not clear and what the relationship. There is only one purpose: To do a complete javaweb project.
First, create the Javawebservlet project
Please refer to the previous article
Second, create a HelloServlet class
In fact, the package can not be created separately, in the creation of the servlet, the Java package column filled with the name: Com.fwbc.servlet can automatically create the package.
Third, create a hello.jsp file
Iv. Modifying the HelloServlet class code
//before modifying the Doget method: protected voidDoget (HttpServletRequest request, httpservletresponse response)throwsservletexception, IOException {//TODO auto-generated Method StubResponse.getwriter (). Append ("Served at:"). Append (Request.getcontextpath ()); } //after modifying the Doget method: protected voidDoget (HttpServletRequest request, httpservletresponse response)throwsservletexception, IOException {//TODO auto-generated Method StubRequest.getrequestdispatcher ("/web-inf/hello.jsp"). Forward (request, response); }
View CodeV. Operation of Javawebservlet Program
Here you can also refer to the previous article, in the browser input: Http://localhost:8080/JavawebServlet/HelloServlet
A complete Javaweb project history 02-hello Servlet