Servlet and Tomcat Tutorial ECT 7130 Download Tomcat
- Slides: 12
Servlet and Tomcat Tutorial ECT 7130
Download Tomcat • http: //ftp. cuhk. edu. hk/pub/packages/apach e. org/tomcat-5/v 5. 5. 28/bin/apachetomcat-5. 5. 28. zip • Put under C: and unzip to C: apachetomcat-5. 5. 28
Starting and Stopping Tomcat • In command line window, set JAVA_HOME=c: Program FilesJavajdk 1. 5. 0_03 (depends on your jdk directory name, for example, maybe yours is jdk 1. 6. x_xx) • C: apache-tomcat-5. 5. 28bin>startup • C: apache-tomcat-5. 5. 28bin>shutdown • Open a browser and type in http: //localhost: 8080
Web Application Directory Structure webapps liangweb Static files, such as HTML files and JSP files in the directory that is the document root of your Web Application *. html *. jsp WEB-INF web. xml classes *. class Packages (e. g. , chapter 35) *. class lib *. jar
Compiling Servlets • Set classpath=%classpath%; c: apache-tomcat 5. 5. 28commonlibservlet-api. jar • Create directory c: apache-tomcat 5. 5. 28webappsliangwebWEB-INFclasses • Copy slide/book/First. Servlet. class into c: apache -tomcat-5. 5. 28webappsliangwebWEBINFclasses
• Download www. cs. armstrong. edu/liang/intro 6 e/suppl ement/web. xml to c: apache-tomcat 5. 5. 28webappsliangwebWEB-INF • Run by typing http: //localhost: 8080/liangweb/First. Servlet
For JDBC Programs • Create a directory liangweb/META-INF • Create a file “context. xml” with the following content <Context path="/liangweb" doc. Base="liangweb" debug="5“ reloadable="true" cross. Context="true"> <Resource name="jdbc/Test. DB" auth="Container“ type="javax. sql. Data. Source” driver. Class. Name="com. mysql. jdbc. Driver url="jdbc: mysql: //localhost; Database. Name=javabook" username="scott" password="tiger" max. Active="300" max. Idle="30" max. Wait="10000" /> </Context>
• Put mysqljdbc. jar under apache-tomcat 5. 5. 28/common/lib/ • You have to startup your My. SQL database (or My. SQL service) with “net start mysql”
Run JDBC Servlet Programs • Under slide/book, you can find Simple. Registration. html and Simple. Registration. class. Do the following tasks: 1. Put the html file under apache-tomcat/webapps/liangweb. Put the class file under apache-tomcat/webapps/liangweb/WEB-INF/classes. 2. Startup tomcat, and type the URL http: //localhost: 8080/liangweb/Simple. Registration. html in a browser. 3. Test whether you can successfully insert the record you input in the form into the database. 4. Before you do that, you have to create a table "Address" with the lastname, firstname, . . . , zip fields in your My. SQL database. You can also test Registration. html/class, Registration. With. Cookie. html/class and Registration. With. Http. Session. html/class in a similar way.
Part II: JSP • Startup tomcat • Copy the following jsp files to apachetomecatwebappsliangweb and run • Current. Time. jsp http: //localhost: 8080/liangweb/Current. Time. jsp • Factorial. jsp http: //localhost: 8080/liangweb/Factorial. jsp • Compute. Loan. html and Compute. Loan. jsp http: //localhost: 8080/liangweb/Compute. Loan. html
• Computer. Loan 1. html (modify this file according to Page 31 of Chapter 40 ppt) • Copy Loan. java to liangwebWEB-INFclasseschapter 35 • Compile it into Loan. class • http: //localhost: 8080/liangweb/Computer. Loan 1. html • Do the same for Computer. Loan 2. html + Loan. class • Do the same for Test. Bean. Scope. jsp + Count. class • Do the same for Factorial. Bean. jsp + Factorial. Bean. class • Do the same for New. Factorial. Bean. jsp + New. Factorial. Bean. class
The JDBC Example • Copy DBLogin. html, DBLogin. Initialization. jsp, Table. jsp, Browse. Table. jsp to liangweb • Copy DBBean. java to liangweb/WEBINF/classes/chapter 35 and compile it to DBBean. class • Startup My. SQL • Run http: //localhost: 8080/liangweb/DBLogin. html
- Java jsp servlet tutorial
- Servlet technology is used to create web application
- Apache tomcat servlet container
- Tomcat tutorial
- Tomcat 6 download
- Fluanoxol
- Contraindications of ect
- Contraindications of ect
- Ect treatment orlando
- Ect voltage chart
- Two technicians are discussing a stepped ect circuit
- Servlet
- Servlet url rewriting