Package com.opensymphony.sitemesh.webapp

# Class SiteMeshFilter

java.lang.Object
com.opensymphony.sitemesh.webapp.SiteMeshFilter

All Implemented Interfaces:
  `javax.servlet.Filter`

Direct Known Subclasses:
  `MultipassFilter`, `PageFilter`

public class SiteMeshFilter extends Object implements javax.servlet.Filter
Core Filter for integrating SiteMesh into a Java web application.

Since:
  SiteMesh 3
Author:
  Joe Walnes, Scott Farquhar

## Field Summary

Fields
Modifier and Type
Field
Description
`private static final String`
`ALREADY_APPLIED_KEY`
`private ContainerTweaks`
`containerTweaks`
`private javax.servlet.FilterConfig`
`filterConfig`

## Constructor Summary

Constructors
Constructor
Description
`SiteMeshFilter()`

## Method Summary

Modifier and Type
Method
Description
`void`
`destroy()`
`void`
`doFilter(javax.servlet.ServletRequest rq, javax.servlet.ServletResponse rs, javax.servlet.FilterChain chain)`
Main method of the Filter.
`private boolean`
`filterAlreadyAppliedForRequest(javax.servlet.http.HttpServletRequest request)`
`void`
`init(javax.servlet.FilterConfig filterConfig)`
`protected ContentProcessor`
`initContentProcessor(SiteMeshWebAppContext webAppContext)`
`protected DecoratorSelector`
`initDecoratorSelector(SiteMeshWebAppContext webAppContext)`
`private Content`
`obtainContent(ContentProcessor contentProcessor, SiteMeshWebAppContext webAppContext, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain chain)`
Continue in filter-chain, writing all content to buffer and parsing into returned `Page` object.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### filterConfig

private javax.servlet.FilterConfig filterConfig

### containerTweaks

private ContainerTweaks containerTweaks

### ALREADY_APPLIED_KEY

private static final String ALREADY_APPLIED_KEY

See Also:
  - Constant Field Values

## Constructor Details

### SiteMeshFilter

public SiteMeshFilter()

## Method Details

### init

public void init(javax.servlet.FilterConfig filterConfig)

Specified by:
  `init` in interface `javax.servlet.Filter`

### destroy

public void destroy()

Specified by:
  `destroy` in interface `javax.servlet.Filter`

### doFilter

public void doFilter(javax.servlet.ServletRequest rq, javax.servlet.ServletResponse rs, javax.servlet.FilterChain chain) throws IOException, javax.servlet.ServletException
Main method of the Filter.

Checks if the Filter has been applied this request. If not, parses the page and applies `Decorator` (if found).

Specified by:
  `doFilter` in interface `javax.servlet.Filter`
Throws:
  `IOException`
  `javax.servlet.ServletException`

### initContentProcessor

protected ContentProcessor initContentProcessor(SiteMeshWebAppContext webAppContext)

### initDecoratorSelector

protected DecoratorSelector initDecoratorSelector(SiteMeshWebAppContext webAppContext)

### obtainContent

private Content obtainContent(ContentProcessor contentProcessor, SiteMeshWebAppContext webAppContext, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain chain) throws IOException, javax.servlet.ServletException
Continue in filter-chain, writing all content to buffer and parsing into returned `Page` object. If `Page` is not parseable, null is returned.

Throws:
  `IOException`
  `javax.servlet.ServletException`

### filterAlreadyAppliedForRequest

private boolean filterAlreadyAppliedForRequest(javax.servlet.http.HttpServletRequest request)