Configuration Web Server Tomcat

Post on 03-Jan-2016

38 views 1 download

description

Configuration Web Server Tomcat. Install JDK 1.6 Install Tom cat 5.5.20 Configure Tom cat for running Servlet C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf Open web.xml with WordPad and uncomment. invoker - PowerPoint PPT Presentation

Transcript of Configuration Web Server Tomcat

Configuration Web Server Tomcat

- Install JDK 1.6- Install Tom cat 5.5.20- Configure Tom cat for running Servlet

C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf

Open web.xml with WordPad and uncomment

<servlet> <servlet-name>invoker</servlet-name> <servlet-class> org.apache.catalina.servlets.InvokerServlet </servlet-class> <init-param> <param-name>debug</param-name> <param-value>0</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet>

<servlet-mapping> <servlet-name>invoker</servlet-name> <url-pattern>/servlet/*</url-pattern> </servlet-mapping>

Test Your Web Server

Open IE:

http://localhost:9999/

Port: 9999

Ask your friend test your web server:

http://192.168.5.125:9999/

Successfully

Unsuccessfully

Fix Web Server

Make sure you start Tomcat Service

(Control Panel -> Administration Tool -> Service -> Start (Apache Tomcat Service)

Make sure you type correct port

First Servlet

import java.io.*; import javax.servlet.*; import javax.servlet.http.*;

public class HelloServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String docType = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " + "Transitional//EN\">\n"; out.println(docType + "<HTML>\n" + "<HEAD><TITLE>Hello</TITLE></HEAD>\n" + "<BODY BGCOLOR=\"#FDF5E6\">\n" + "<H1>Hello First Servlet</H1>\n" + "</BODY></HTML>"); } }

First Servlet

Folder Location for Servlet Class fileC:\Program Files\Apache Software Foundation\

Tomcat 5.5\webapps\ROOT\WEB-INF\classes

If you change servlet code, you should restart the Tomcat Service to updating new code

Test your Servlet:http://localhost:9999/servlet/HelloServlet

First JSP

<html> <head> <meta http-equiv="Content-Type" content="text/html;

charset=windows-1252"> <title>First Hello JSP</title> </head> <body> <% out.println("<H1>Hello JSP </H1>"); %> </body> </html>

Run the first JSP

Folder Location for Servlet Class file

C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT\hello.jsp

Test your JSP File: Open IE

http://localhost:9999/hello.jsp

Input Class

ESL Registration

Student Grade / Semester

ESL Registration for Officer Module

Design Web Page for inputting An Employee

An Employee has first name, last name, id, birthday, gender, Type of employee (Full Time or Part time), education (B.A. , Master, or Doctor)