1 / 18

Intro to Servlets

Intro to Servlets. Lec 26. Web-Based Enterprise Applications in Java. Figure shows a simplified view of one application and its layers. Java Servlets. JVM. Request. Client/ browser. Server. Servlet. Response. Extends the functionality of the server by

scott-miles
Download Presentation

Intro to Servlets

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 JVM Request Client/ browser Server Servlet Response 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. Software Requirements • 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. Environment Setup Steps • Download the Apache Tomcat Server • Install Tomcat • Set the JAVA_HOME variable • Set the CATALINA_HOME variable • Set the CLASSPATH variable • Test the Server

  11. 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. 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.9generally referred as install_dir • Installing .exe file • Check the handouts

  13. 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. 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. 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. Test the Server • Before making your own Servlets and JSP, verify that the server can start • Runinstall_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

More Related