Tomcat, JSP, Servlet Tutorial
Outline Setting Up the JSP Environment Servlet JSP Setting Up the MySQL Environment e-commerce web application
Installing the Java Software Development Kit JDK 5.0 Update 4 (SDK/JDK) Choose SDK not JRE JSP requires a compiler in SDK d.jsp d.jsp
Set JAVA_HOME environment variable Set JAVA_HOME to the location of Java SDK (C:\Program Files\Java\jdk1.5.0_04)
Install Tomcat Binary exe s/downloads_tomcat-5.cgi s/downloads_tomcat-5.cgi
Set CATALINA_HOME environment variable Set CATALINA_HOME to the location of Tomcat (C:\Program Files\Apache Software Foundation\Tomcat 5.5)
Example Web Application Overview Start Tomcat by bin/tomcat5w
Outline Setting Up the JSP Environment Servlet JSP Setting Up the MySQL Environment e-commerce web application
Download the source code of servlet HelloWorldExample.java e.java
Deploy a servlet – Step 1 Write the servlet Java code Copy Tomcat 5.5\common\lib\servlet- api.jar to jre1.5.0_04\lib\ext Compile javac HelloWorldExample.java Copy HelloWorldExample.class to Tomcat 5.5\webapps\ROOT\WEB- INF\classes
Deploy a servlet – Step 2 Add servlet mapping to Tomcat 5.5\webapps\ROOT\WEB-INF\web.xml
HelloWorldExample servlet HelloWorldExample HelloWorldExample
Outline Setting Up the JSP Environment Servlet JSP Setting Up the MySQL Environment e-commerce web application
Write JSP code Write JSP pages then deploy them as html files contains Java code Copy JSP code from
Deploy JSP Save JSP as HelloWorld.jsp to Tomcat 5.5\webapps\ROOT See the result at
Result of a JSP page The same result as the servlet replies Much easier
Outline Setting Up the JSP Environment Servlet JSP Setting Up the MySQL Environment e-commerce web application
Install MySQL 4.1 Windows (x86) a /4.1.html /4.1.html
Configure root password \bin\mysql – u root USE mysql UPDATE user SET password=password('root3394') where user='root'; FLUSH PRIVILEGES; quit
Install EMS MySQL Manager 3
Create a database table
Handset table Create a handset table with fields manufacturer model_name price
Data in the handset table EMS lets you to input data easily
Outline Setting Up the JSP Environment Servlet JSP Setting Up the MySQL Environment e-commerce web application
Use MySQL on Tomcat by MySQL JDBC Driver Source and Binaries (zip) ctor/j/3.1.html ctor/j/3.1.html Input mysql-connector-java bin.jar to ROOT\WEB-INF\lib
Result of HandsetList.jsp
Reference JavaServer Pages By Hans Bergsten