Key steps for servlet version two

We have two main things to do: recompile the servlet and deploy the model class.

Compiling the servlet

We’ll use the same compiler command that we used when we built the first version of the servlet.

image with no caption

Deploying and testing the web app

Now, in addition to the servlet, we also have to deploy the model. The key steps are:

1 - Move a copy of the servlet .class file to: ../Beer-v1/WEB-INF/classes/com/example/web/ This replaces the version one servlet class file!

2 - Move a copy of the model’s .class file to: ../Beer-v1/WEB-INF/classes/com/example/model/

3 - Shutdown and restart tomcat

image with no caption

4 - Test the app via form.html, the final browser output should be something like:

image with no caption

Beer Selection Advice try: Jack Amber try: Red Moose

image with no caption

Get Head First Servlets and JSP, 2nd Edition 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.