Tomcat JSP Servlet Tutorial Outline n n n

  • Slides: 31
Download presentation
Tomcat, JSP, Servlet Tutorial

Tomcat, JSP, Servlet Tutorial

Outline n n n Setting Up the JSP Environment Servlet JSP Setting Up the

Outline n n n Setting Up the JSP Environment Servlet JSP Setting Up the My. SQL Environment e-commerce web application

Installing the Java Software Development Kit n JDK 5. 0 Update 4 (SDK/JDK) n

Installing the Java Software Development Kit n JDK 5. 0 Update 4 (SDK/JDK) n n n Choose SDK not JRE JSP requires a compiler in SDK http: //java. sun. com/j 2 se/1. 5. 0/downloa d. jsp

Set JAVA_HOME environment variable n Set JAVA_HOME to the location of Java SDK (C:

Set JAVA_HOME environment variable n Set JAVA_HOME to the location of Java SDK (C: Program FilesJavajdk 1. 5. 0_04)

Install Tomcat 5. 5 n 5. 5. 9 n Binary n n 5. 5.

Install Tomcat 5. 5 n 5. 5. 9 n Binary n n 5. 5. 9 exe http: //jakarta. apache. org/site/download s/downloads_tomcat-5. cgi

Set CATALINA_HOME environment variable n Set CATALINA_HOME to the location of Tomcat (C: Program

Set CATALINA_HOME environment variable n Set CATALINA_HOME to the location of Tomcat (C: Program FilesApache Software FoundationTomcat 5. 5)

Example Web Application Overview n Start Tomcat by bin/tomcat 5 w

Example Web Application Overview n Start Tomcat by bin/tomcat 5 w

Outline n n n Setting Up the JSP Environment Servlet JSP Setting Up the

Outline n n n Setting Up the JSP Environment Servlet JSP Setting Up the My. SQL Environment e-commerce web application

Download the source code of servlet Hello. World. Example. java n http: //140. 116.

Download the source code of servlet Hello. World. Example. java n http: //140. 116. 82. 24/Hello. World. Exampl e. java

Deploy a servlet – Step 1 n n Write the servlet Java code Copy

Deploy a servlet – Step 1 n n Write the servlet Java code Copy Tomcat 5. 5commonlibservletapi. jar to jre 1. 5. 0_04libext Compile javac Hello. World. Example. java Copy Hello. World. Example. class to Tomcat 5. 5webappsROOTWEBINFclasses

Deploy a servlet – Step 2 n Add servlet mapping to Tomcat 5. 5webappsROOTWEB-INFweb.

Deploy a servlet – Step 2 n Add servlet mapping to Tomcat 5. 5webappsROOTWEB-INFweb. xml

Hello. World. Example servlet n http: //140. 116. 82. 24/example_servlet/ Hello. World. Example

Hello. World. Example servlet n http: //140. 116. 82. 24/example_servlet/ Hello. World. Example

Outline n n n Setting Up the JSP Environment Servlet JSP Setting Up the

Outline n n n Setting Up the JSP Environment Servlet JSP Setting Up the My. SQL Environment e-commerce web application

Write JSP code n n n Write JSP pages then deploy them as html

Write JSP code n n n Write JSP pages then deploy them as html files <% %> contains Java code Copy JSP code from http: //140. 116. 82. 24/jsp_code. htm

Deploy JSP n n Save JSP as Hello. World. jsp to Tomcat 5. 5webappsROOT

Deploy JSP n n Save JSP as Hello. World. jsp to Tomcat 5. 5webappsROOT See the result at http: //140. 116. 82. 24/Hello. World. jsp

Result of a JSP page n n The same result as the servlet replies

Result of a JSP page n n The same result as the servlet replies Much easier

Outline n n n Setting Up the JSP Environment Servlet JSP Setting Up the

Outline n n n Setting Up the JSP Environment Servlet JSP Setting Up the My. SQL Environment e-commerce web application

Install My. SQL 4. 1 n n Windows (x 86) 4. 1. 13 a

Install My. SQL 4. 1 n n Windows (x 86) 4. 1. 13 a http: //dev. mysql. com/downloads/mysql /4. 1. html

Configure root password n binmysql –u root n n USE mysql UPDATE user SET

Configure root password n binmysql –u root n n USE mysql UPDATE user SET password=password('root 3394') where user='root'; FLUSH PRIVILEGES; quit

Install EMS My. SQL Manager 3 n n Install EMS My. SQL Manager 3

Install EMS My. SQL Manager 3 n n Install EMS My. SQL Manager 3 http: //www. sqlmanager. net/

Create a database table

Create a database table

Handset table n Create a handset table with fields n n n manufacturer model_name

Handset table n Create a handset table with fields n n n manufacturer model_name price

Data in the handset table n EMS lets you to input data easily

Data in the handset table n EMS lets you to input data easily

Outline n n n Setting Up the JSP Environment Servlet JSP Setting Up the

Outline n n n Setting Up the JSP Environment Servlet JSP Setting Up the My. SQL Environment e-commerce web application

Use My. SQL on Tomcat by My. SQL JDBC Driver n n n Source

Use My. SQL on Tomcat by My. SQL JDBC Driver n n n Source and Binaries (zip) http: //dev. mysql. com/downloads/conne ctor/j/3. 1. html Input mysql-connector-java-3. 1. 10 bin. jar to ROOTWEB-INFlib

Result of Handset. List. jsp n http: //140. 116. 82. 24/Handset. List. jsp

Result of Handset. List. jsp n http: //140. 116. 82. 24/Handset. List. jsp

Reference n Java. Server Pages By Hans Bergsten

Reference n Java. Server Pages By Hans Bergsten