Servlet Day 2

Source: Internet
Author: User

 

The relative path of files in Web applications starts from the F:/yangxp/tools/Apache-Tomcat-5.5.12/bin directory.

F:/yangxp/tools/Apache-Tomcat-5.5.12/bin
F:/yangxp/tools/Apache-Tomcat-5.5.12/webapps/showusercount/WEB-INF/classes
="
../Webapps/showusercount/WEB-INF/classes

Interface problems:
All methods in the interface must be implemented, even if it is empty. Leading to many invalid redundancy operations
Solution:
Implemented by a third party according to the interface, all of which are empty
Publish the implementation class to the user. Users only need to overwrite the methods they are interested in.
----- Adapter mode (*** adapter)
General Resource (220 V) ---- adapter ----> applicable to current electrical voltage

Servlet interface servletconfig Interface
|
Genericservlet (Abstract adapter class)
| Servletcontext getservletcontext ()
| Obtain the context of the current processing class (current Web Application)
|
Httpservlet (generic implementation Class Based on HTTP Protocol)
| Void Service (servletrequest req, servletresponse res)
The Web Container directly forwards requests and responses to the following methods.
| Protected void Service (httpservletrequest req, httpservletresponse resp)
[Programmers can override this method and write service processes]
This method automatically submits forms based on the client,
Forward requests and responses to the method corresponding to the submission method
For example, if form is submitted in get mode, it is called:
| Protected void doget (httpservletrequest req, httpservletresponse resp)
[We recommend that programmers overwrite doget & dopost]
Myservlet

 

Servlet interface: mainly defines the servlet lifecycle Method
Servletconfig interface: defines servlet methods for obtaining information transmitted by external containers (Web. XML)
Genericservlet implementation class: implements the methods of the above two interfaces, and adds the log record Method
Httpservlet: Generic implementation Class Based on HTTP protocol

Http: // localhost: 8088/stumgmt/add.html
Http: // localhost: 8088/stumgmt/addstudent? Name = Heihei & Birthday = 1989-3-3
Relative Path: relative to the current path

HTML: absolute path, starting from 8088

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.