How to deploy the PhoneBook servlet application on Apache Tomcat 1. In the webapps directory of the Apache Tomcat server create a sub-directory with the name of your application. In our example the sub-directory is named servlet_examples. 2. a. In the servlet_examples sub-directory, create a sub-directory named WEB-INF. b. In the servlet_Examples sub-directory place the phonebook.html file 3. a. In the WEB-INF sub-directory, create another 2 sub-directories, classes and src. b. In the WEB-INF sub-directory, place the web.xml file which has the following content: <?xml version="1.0" encoding="ISO-8859-1"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web- app_2_5.xsd" version="2.5"> <display-name>Welcome to Tomcat</display-name> <description> Welcome to Tomcat </description> <servlet> <servlet-name>phonebook</servlet-name> <servlet-class>PhoneBook</servlet-class> </servlet> <servlet-mapping> <servlet-name>phonebook</servlet-name> <url-pattern>/PhoneBook/*</url-pattern> </servlet-mapping> </web-app> 4. In the src sub-directory, you should place the PhoneBook.java file 5. In the classes sub-directory place the PhoneBook.class file (you should compile PhoneBook.java on your computer to obtain the PhoneBook.class file) 6. You should restart the Apache Tomcat server. 7. You have to drop the test database which comes with MySQL by using the following commands in a Windows console: - log into MySQL: mysql -uroot -p - drop the test database: drop test - create a new test database: create test - exit the MySQL: exit 8. You have to use the following command to deploy the MySQL database test: mysql -uroot -p test < test.sql At this point your application should be functional. Go in the web browser and type in the URL: http://localhost:8080/servlet_examples/PhoneBook The browser should display the PhoneBook page.
Pages to are hidden for
"PhoneBook_Deployment.doc"Please download to view full document