Adapting a Servlet for Wireless Devices

In the Browser Detection and Media sections of this chapter, we looked at using different style sheets for different types of browsers. Now we're going to take that a step farther, creating a new style sheet for our Web phone.

Before we can even think about seeing it, however, we need to make a couple of changes. First of all, as we mentioned earlier, the phone isn't going to understand any requests that come back with a MIME-type other than text/vnd.wap.wml. So, the first thing we need to do is to tell the servlet to output the appropriate MIME-type. In Listing 9.17, we'll use the media value, which we're already checking for, to decide on the appropriate MIME-type.

Listing 9.17. ShowCatalog.java: Adjusting ...

Get XML and Java™ from scratch now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.