All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mockrunner.example.servlet.ImageButtonFilter Maven / Gradle / Ivy

package com.mockrunner.example.servlet;

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;

/**
 * This example filter replaces request parameters from
 * submit images (<input type="image"/>)
 * with the appropriate submit button parameters
 * (<input type="submit"/>), i.e. if the
 * image name is image, the two parameters
 * image.x and image.y will be replaced
 * by one parameter image. This makes it possible
 * to handle submit images like normal submit buttons.
 */
public class ImageButtonFilter implements Filter
{
   public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
   {
        if(request instanceof HttpServletRequest)
        {
            ImageButtonRequestWrapper wrapper = new ImageButtonRequestWrapper((HttpServletRequest)request);
		    chain.doFilter(wrapper, response);
		}
        else
        {
            chain.doFilter(request, response);
        }
   }

   public void init(FilterConfig filterConfig)
   {

   }

   public void destroy()
   {

   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy