Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Filter

  1. #1
    Regular Coder
    Join Date
    Apr 2007
    Posts
    179
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Filter

    In the web.xml, there is a filter section, such as:


    <filter>
    <filter-name>TestFilter</filter-name>
    <filter-class>com.test.TestFilter</filter-class>
    </filter>


    --Why do we need filter? or, under what circumstances should I use filter otherthan other class?

    (Seems like I can use the servlet mapping to achieve the same)


    Thanks


    Scott
    Last edited by otnj2ee; 02-20-2008 at 07:55 PM.

  • #2
    Regular Coder
    Join Date
    Jan 2008
    Location
    Willow Grove, PA
    Posts
    169
    Thanks
    1
    Thanked 27 Times in 27 Posts
    From how I understand it, a servlet is specific to a url.

    http://www.example.com/myServlet

    Hitting that url will run that servlet. Generally a whole web page is output.

    http://java.sun.com/j2ee/tutorial/1_...Servlets2.html

    As for filters, they provide specific bits of functionality without using page includes. An example might be that you want to inject certain content at the beginning and end of each page.

    http://java.sun.com/products/servlet/Filters.html


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •