package it.mice.voila.runtime.web.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

/**
 * Created by IntelliJ IDEA.
 * User: zzy9v4
 * Date: 26-giu-2006
 * Time: 15.24.51
 * To change this template use File | Settings | File Templates.
 */
public class DisableJavascriptFilter implements Filter {
	public static final String DISABLE_JAVASCRIPT = "disableJavascript";

    /**
     * {@inheritDoc}
     */
    public void init(FilterConfig filterConfig)
    {
    }

    /**
     * {@inheritDoc}
     */
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
        throws IOException, ServletException
    {
    	((HttpServletRequest)servletRequest).getSession().setAttribute(DISABLE_JAVASCRIPT, servletRequest.getParameter(DISABLE_JAVASCRIPT));
		filterChain.doFilter(servletRequest, servletResponse);
    }

	/**
     * {@inheritDoc}
     */
    public void destroy()
    {
        // nothing to destroy
    }
}