Which is the best way to handle WAP and HTML requests dynamically in the same JSP?

Serge Knystautas

While there are numerous approaches that might allow this, I believe it is a bad design to use the same JSP to serve both HTML and WML. The presentation of your data and the user interface is profoundly different between a 800x600x16.7 million colors browser display and an 8-line black/white cell phone. This means your links and content organization will be very different, and trying to force fit generating these very different user interfaces into single files is very difficult.

Your first goal should be to make sure you've properly separated your data and logic layer from your presentation layer. This means business logic and data are readily available in your JSP, and someone can write JSPs without much technical expertise. The JSP tag libraries allow you to do this wonderfully. Once you accomplish this separation, your JSPs solely handle the presentation, and this allow you to quickly and efficiently build and maintain two versions of your site... one set of JSPs that serve HTML and one set of JSPs that serve WML.