Presentation is loading. Please wait.

Presentation is loading. Please wait.

Intro to Servlets Lec 26. Web-Based Enterprise Applications in Java Figure shows a simplified view of one application and its layers.

Similar presentations


Presentation on theme: "Intro to Servlets Lec 26. Web-Based Enterprise Applications in Java Figure shows a simplified view of one application and its layers."— Presentation transcript:

1 Intro to Servlets Lec 26

2 Web-Based Enterprise Applications in Java Figure shows a simplified view of one application and its layers.

3 Java Servlets Client/ browser Server Request Response Servlet JVM Extends the functionality of the server by Generating HTML pages dynamically

4 What Do They Do? Anything that java can do (e.g. connect to database services) Handle data/requests sent by users (clients) Create and format results Send results back to user

5 Java Servlets Advantages over other SSP technologies:  Can use the Java APIs e.g. JDBC.  Persistent between invocations, avoiding process instantiations.  Portable across operating systems and servers.  Good security.  Is integrated closely with the J2EE environment.

6 Software Requirements

7 To use Java servlets, following softwares will be needed  J2SE  Additional J2EE based libraries for servlets such as servlet-api.jar, jsp-api.jar. You can download these APIs separately but they are also available with the web server you’ll be using.  A capable servlet web engine (web server)

8 Jakarta Servlet Engine (Tomcat) Jakarta is an Apache project  Tomcat is one of its subprojects Tomcat is the official reference implementation for the Java servlet and JavaServer pages technologies (according to Sun’s specifications) Tomcat is developed in an open and participatory environment and released under the Apache software license

9 Environment Setup

10 Steps 1. Download the Apache Tomcat Server 2. Install Tomcat 3. Set the JAVA_HOME variable 4. Set the CATALINA_HOME variable 5. Set the CLASSPATH variable 6. Test the Server

11 1.Download the Apache Tomcat Server From the http://jakarta.apache.org  Download the zip file for the current release of Jakarta Tomcat  For windows, there is also a.exe installer

12 2.Install Tomcat Installing.zip file  Unzip the file into a location (e.g. C:\)  The zip file had embedded subdirectories (e.g., jakarta-tomcat-5.5.9 ).  C:\ jakarta-tomcat-5.5.9 generally referred as install_dir Installing.exe file  Check the handouts

13 3.Set the JAVA_HOME variable Set the JAVA_HOME environment variable to tell Tomcat where to find Java This variable should list the base JDK installation directory, not the bin subdirectory JAVA_HOME = c:\j2sdk1.5.0

14 4.Set the CATALINA_HOME variable Set the CATALINA_HOME environment variable to refer to the top-level directory of the Apache Tomcat installation, not the bin subdirectory CATALINA_HOME = c:\jakarta-tomcat-5.5.9

15 5.Set the CLASSPATH variable Since servlets and JSP are not part of the J2SE, javac doesn’t know about the servlet and jsp classes The standard Tomcat locations for these files are  install_dir/common/lib/servlet-api.jar  install_dir/common/lib/jsp-api.jar You need to include both files in your CLASSPATH

16 6.Test the Server Before making your own Servlets and JSP, verify that the server can start Run install_dir/bin/startup.bat Enter the URL http://localhost:8080 in your browser and make sure you will get the Tomcat homepage

17 Lets do it LIVE

18 Tomcat Directory Structure my-app


Download ppt "Intro to Servlets Lec 26. Web-Based Enterprise Applications in Java Figure shows a simplified view of one application and its layers."

Similar presentations


Ads by Google