Mobile Redirect filter ver. 1.2


This is a Java servlet filter (as per Servlet API 2.3). This filter lets you redirect incoming requests from mobile users to the special site.

How to use it:

a) download mobileredirectflt.jar and save it in WEB-INF/lib

b) describe this filter in web.xml. You must describe an initial parameter host - your site for mobile users.
 


<filter>
  <filter-name>MobileRedirectFilter</filter-name>
  <filter-class>com.cj.mobile.MobileRedirectFilter</filter-class>
  <init-param>
    <param-name>host</param-name>
    <param-value>http://m.myserver.com</param-value>
  </init-param>
</filter>

c) describe a mapping for this filter in web.xml. E.g.:
 


<filter-mapping>
  <filter-name>MobileRedirectFilter</filter-name>
  <url-pattern>*.jsp</url-pattern>
</filter-mapping>

in this example filter will be on for the each .jsp file

And now when some .jsp page (covered by MobileRedirectFilter mapping) is requested by the mobile MobileRedirectFilter may redirect (or forward) request to the specified URL. If target URL starts with http than request will be redirected. Otherwise filter assumes a local resource and forwards request. The query string (if any) will be passed to the new site as is.

For dealing with your mobile users right from JSP (and/or ColdFusion) pages you can use Mobile taglib.

   For downloading:

    Redirect package:  mobileredirectflt.jar
 

 ©  Coldbeans     Comments?

See also JSOS - the largest collection of servlets and filters.

     

Also in JSOS: