Use Java's lisener,filter,servlet.

Source: Internet
Author: User

One: servlet

First need a class testservlet inherit HttpServlet, rewrite the method inside, Doget,dopost

Then configure the information in the Config file Web. xml:

<servlet><Servlet-name>Testservlet</Servlet-name><Servlet-class>Com.test.TestServlet</Servlet-class></servlet><servlet-mapping><Servlet-name>Testservlet</Servlet-name></Url-pattern>/testservlet<Url-pattern></servlet-mapping>


Two: Filter

The Testfilter class needs to implement the filter interface to implement all the methods inside, where the Init method is executed when the server is started.

The Dofilter method is to intercept the code that executes after the request is executed, and after execution, the Chain.dofilter method forwards the request to the filter next to it, if not the resource that you requested.

<Filter><Filter-name>Testfilter</Filter-name><Filter-class>Com.test.TestFilter</Filter-class></Filter></filter-mapping><Filter-name>Testfilter</Filter-name><Url-pattern>/testfilter</Url-pattern></filter-mapping>

Three: Listener

There are many kinds of listener in Java: 1: When the client comes in and responds to the request, it is called when the value of the 2:request property changes, and when the property value in the 3:session changes.

4:web is invoked when the service is opened and closed. Wait a minute

You can use this listener if you want to process each request.

<listener><listener-class>TestListener</listener-class></listener>

For more information, you can see 52072655

Use Java's lisener,filter,servlet.

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.