O'Reilly logo

Head First Servlets and JSP, 2nd Edition by Bert Bates, Bryan Basham, Kathy Sierra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The HTML for the initial form page

The HTML is simple—it puts up the heading text, the drop-down list from which the user selects a beer color, and the submit button.

image with no caption

Q:

Q: Why is the form submitting to “SelectBeer.do” when there is NO servlet with that name? In the directory structures we looked at earlier, I didn’t see anything that had the name “SelectBeer.do”. And what’s with the “.do” extension anyway?

A:

A: SelectBeer.do is a logical name, not an actual file name. It’s simply the name we want the client to use! In fact the client will NEVER have direct access to the servlet class file, so you won’t, for example, create an HTML page with a link or action that includes a path to a servlet class file.

The trick is, we’ll use the XML Deployment Descriptor (web.xml) to map from what the client requests (“SelectBeer.do”) to an actual servlet class file the Container will use when a request comes in for “SelectBeer.do”. For now, think of the “.do” extension as simply part of the logical name (and not a real file type). Later in the book, you’ll learn about other ways in which you can use extensions (real or made-up/logical) in your servlet mappings.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required