Monday, December 6, 2010

Mobilize Your Java Web Application

Mobile web access is growing by 30% every year, so do consider to make your Java web application work well on a small screen. In this post, I'm going to analyze a typical java web application and make it mobile access ready.

Usually, a Java web application consist two parts:

  • 1. the layout template framework, such as Tiles, or Sitemesh.

  • 2. a web framework to handle request and return JSP result page, such as Struts, Spring MVC.

Take my favorite combination, Sitemesh for layout template engine and Spring MVC as web framework for example, there will be two (or three) step for a Sitemesh + Spring MVC web application to go:


for example, in my project, the default.jsp is the default decartor for PC browser. I personally use BlueprintCSS framework, jQuery and jQuery UI to tackle some cross browser problem.

The default-mobile.jsp is for mobile browser and jQuery Mobile can handle browser compatablity too.

For the result page, I also provide two version. Therefore, when user is using mobile phone, Spring MVC will intercept request and return the mobile version result page. Sitemesh will render the mobile version result with mobile decorator. So the mobile user will get tidy, fast mobile view.

In addition, if you intend to develop a mobile application for your web application, Phonegap might be your best choice since you can leverage your css, html and javascript skill and multi-mobile platform supported. Because of the cross domain restriction, JSONP supported will be very helpful for developer.

0 comments: