KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openi > web > ClientWindowSizeFilter


1 /*********************************************************************************
2  * The contents of this file are subject to the OpenI Public License Version 1.0
3  * ("License"); You may not use this file except in compliance with the
4  * License. You may obtain a copy of the License at
5  * http://www.openi.org/docs/LICENSE.txt
6  *
7  * Software distributed under the License is distributed on an "AS IS" basis,
8  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
9  * the specific language governing rights and limitations under the License.
10  *
11  * The Original Code is: OpenI Open Source
12  *
13  * The Initial Developer of the Original Code is Loyalty Matrix, Inc.
14  * Portions created by Loyalty Matrix, Inc. are
15  * Copyright (C) 2005 Loyalty Matrix, Inc.; All Rights Reserved.
16  *
17  * Contributor(s): ______________________________________.
18  *
19  ********************************************************************************/

20 package org.openi.web;
21
22 import java.io.IOException JavaDoc;
23
24 import javax.servlet.Filter JavaDoc;
25 import javax.servlet.FilterChain JavaDoc;
26 import javax.servlet.FilterConfig JavaDoc;
27 import javax.servlet.ServletException JavaDoc;
28 import javax.servlet.ServletRequest JavaDoc;
29 import javax.servlet.ServletResponse JavaDoc;
30 import javax.servlet.http.HttpServletRequest JavaDoc;
31 import javax.servlet.http.HttpSession JavaDoc;
32
33 import org.apache.log4j.Logger;
34
35 /**
36  * filter that allows the user to specify width and height at any time.
37  * relevant for resizing.
38  */

39 public class ClientWindowSizeFilter implements Filter JavaDoc{
40     private static Logger logger = Logger.getLogger(ClientWindowSizeFilter.class);
41     private FilterConfig JavaDoc filterConfig;
42
43     /**
44      *
45      */

46     public ClientWindowSizeFilter() {
47         super();
48         // TODO Auto-generated constructor stub
49
}
50
51     /* (non-Javadoc)
52      * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
53      */

54     public void init(FilterConfig JavaDoc filterConfig) throws ServletException JavaDoc {
55         this.filterConfig = filterConfig;
56         
57     }
58
59     /*
60      * Allow user to specify client window height and width at any time, any request
61      */

62     public void doFilter(ServletRequest JavaDoc servletRequest, ServletResponse JavaDoc servletResponse,
63             FilterChain JavaDoc filterChain) throws IOException JavaDoc, ServletException JavaDoc {
64         long start = System.currentTimeMillis();
65         HttpServletRequest JavaDoc request = (HttpServletRequest JavaDoc)servletRequest;
66         HttpSession JavaDoc session = request.getSession();
67         
68         // client window width and height stored in session.
69
if (request.getParameter("clientWindowHeight") != null) {
70             session.setAttribute("clientWindowHeight",
71                 request.getParameter("clientWindowHeight"));
72         }
73
74         if (request.getParameter("clientWindowWidth") != null) {
75             session.setAttribute("clientWindowWidth",
76                 request.getParameter("clientWindowWidth"));
77         }
78         // logger.debug("completed in: " + (System.currentTimeMillis()-start) + "ms");
79
filterChain.doFilter(request, servletResponse);
80     }
81
82     /* (non-Javadoc)
83      * @see javax.servlet.Filter#destroy()
84      */

85     public void destroy() {
86         // TODO Auto-generated method stub
87

88     }
89
90 }
91
Popular Tags