Lab 4: Deploying a Web Application
Objective: In this lab, you will deploy a Web application that uses internationalization to display text in both English and Spanish.
-
Change directories to labs/Lab_04. You should see four .class files in this directory
-
The Java developer has provided you with these four bytecode files, but does not know how to deploy them on Tomcat. Your task is to create the appropriate directory structure and deploy these files so that this application is deployed to a context named /payment. You will need to know the following information to accomplish this successfully:
-
The Servlet class files ShowText.class and RequestDemo.class are in a package named "demos"
-
The class files Messages.class and Message_es.class are in a package named "text". These are not Java Servlets, just utility classes
-
The RequestDemo Servlet must be deployed to the URL /payment/go
-
The ShowText Servlet must be deployed to the URL /payment/showtext
-
Create the necessary subdirectories of webapps to deploy this application. The web.xml file for this application has been written for you. It is located Lab_04/solution/payment/WEB-INF folder. Copy this file into the appropriate folder of your Web application.
-
Once you have it deployed, open a browser and point it to http://your_ip_address:8080/payment/go. You should see a simple form for entering your name and credit card number, and the text should appear in English. When you see this page, you have deployed the application successfully.
-
This application uses Java internationalization to display pages in both English and Spanish. If you change your Web browser settings to use Spanish (es), then you should see a page similar to the one in the slide.
Summary: In this lab, you followed all of the steps necessary to deploy a Java web application. You probably learned more than you need to even know! In general, your Java web developers should be creating the WAR files for you, but it is always great to have that understanding of how Java servlets are deployed and executed.