File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Filtering Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Filtering" Watch "Filtering" New topic
Author

Filtering

Anuradha Sridharan
Greenhorn

Joined: Nov 03, 2003
Posts: 3
Hi all,
Could someone explain to me what is the concept of filtering in Servlets? Any pointers to references related to this topic are also welcome.
Thanks
Anu.
Mathias Nilsson
Ranch Hand

Joined: Oct 13, 2003
Posts: 107
A filter can be applied to one or more servlet/JSP files. A filter is an
object that can transform a request or modify a response. It can
preprocess a request BEFORE it reaches a servlet and it can preprocess a response after it leaves the servlet.
  • A client sends a request
  • The filter intercepts the client request
  • The filter examines and can modify the request header and request data by using its own custom request to wrap araond the intercepted request object
  • the filter propagates the request to the servlet
  • the servlet generates a response a flushes it.
  • the filter intercepts the response
  • the filter can modify the headers and data by using its own custom response
  • Once completed, the filter sends the newly filtered response to the client


  • A filter must implement the javax.servlet.Filter interface.
    Let's say we create a filter.

    then in your web.xml file

    after this you can either filter specific servlets or URL patterns
    specific servlet

    Url patterns

    Hope this helps you


    SCJP2 , MCP( 70-229 ) , Preparing For SCWDC
    Mathias Nilsson
    Ranch Hand

    Joined: Oct 13, 2003
    Posts: 107
    Check this link out
    http://developer.java.sun.com/developer/technicalArticles/Servlets/servletapi2.3/
    [ November 04, 2003: Message edited by: Mathias Nilsson ]
    Mathias Nilsson
    Ranch Hand

    Joined: Oct 13, 2003
    Posts: 107
    http://www.rollerweblogger.org/page/roller/20030606
    the mapping for jsp files should be

    And not

    // Mathias
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Filtering
     
    Similar Threads
    servlet filtering
    SpamNet
    servlet filtering
    servlet
    interdependent drop down list select mysql jsp