Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Java Servlets on Jakarta Tomcat

Similar presentations


Presentation on theme: "Introduction to Java Servlets on Jakarta Tomcat"— Presentation transcript:

1 Introduction to Java Servlets on Jakarta Tomcat
Novell BrainShare 2002 Introduction to Java Servlets on Jakarta Tomcat Moises Morales Software Engineer Novell, Inc. DCB124—Introduction to Java Servlets on Jakarta Tomcat

2 Introduction Goals of the session one Net
Novell BrainShare 2002 Introduction Goals of the session Learn about Java servlets: Their architecture, uses, and how to write them* Learn about Jakarta Tomcat Servlet Gateway *Some background of Java programming is expected one Net The servlet technology is Java-based and cross-platform, making it possible to run of different networks more securely and efficiently and powering the web by giving solutions for eCommerce DCB124—Introduction to Java Servlets on Jakarta Tomcat

3 Vision…one Net Mission
Novell BrainShare 2002 Vision…one Net A world where networks of all types—corporate and public, intranets, extranets, and the Internet—work together as one Net and securely connect employees, customers, suppliers, and partners across organizational boundaries Mission To solve complex business and technical challenges with Net business solutions that enable people, processes, and systems to work together and our customers to profit from the opportunities of a networked world DCB124—Introduction to Java Servlets on Jakarta Tomcat

4

5 Origin of Servlets: How They Started
Novell BrainShare 2002 Origin of Servlets: How They Started Java applets vs. servlets Applets are Java programs which can be embedded directly into the webpages to add more functionality Applet gets downloaded to the client and then executed when we hit a web page with it If the size of applet grows, it increases download time and is inefficient Applets are also dependent on browsers The output can look different, raising compatibility issues If an applet is changed to be server-side, then it is executed on the server rather than the client This can avoid the aforementioned drawbacks Java servlets are like applets, not as graphical but executed on the server DCB124—Introduction to Java Servlets on Jakarta Tomcat

6 Origin of Servlets (cont.)
Novell BrainShare 2002 Origin of Servlets (cont.) CGI vs. servlets Common Gateway Interface (CGI), traditionally used for developing web applications CGI is server-side and the web server creates a process to listen to requests, which are processed and send back to the server, then replied to the client With each CGI request, as new process is created and this could be cumbersome when there are too many requests Wastes of resources and slows the response time Browser could timeout if the CGI request abnormally terminates, as they run on different process than the web servers Java servlets can accomplish all the tasks of CGI more efficiently Servlets have session tracking built in DCB124—Introduction to Java Servlets on Jakarta Tomcat

7 What are Servlets? Servlets are dynamically-loaded Java modules that extends the functionality of a web server by taking requests from the client and executing them on the server Java servlets runs fully inside the JVM JVM Request Client/ browser Server Servlet Response

8 Why Servlets? Uses Practical application Portable Efficient Secure
Robust Integration Practical application eCommerce

9 Servlet Architecture Servlets are based on two main packages
Novell BrainShare 2002 Servlet Architecture Servlets are based on two main packages javax.servlet javax.servlet.http GenericServlet HttpServlet This class is extended from GenericServlet class DCB124—Introduction to Java Servlets on Jakarta Tomcat

10 Servlet Architecture (cont.)
Novell BrainShare 2002 Servlet Architecture (cont.) Lifecycle of a servlet init() This method is called as soon as the servlet is instantiated service() This method then handles the client requests destroy() To mark the end of the servlet, for example, when the servlet service is completed, this method is used DCB124—Introduction to Java Servlets on Jakarta Tomcat

11 Hello World Example import java.io.*; import javax.servlet.*;
Novell BrainShare 2002 Hello World Example import java.io.*; import javax.servlet.*; import javax.servlet,http.*; public class HelloWorld extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); out.println(“Hello World!”); } DCB124—Introduction to Java Servlets on Jakarta Tomcat

12 Then What Are JSPs? Java server pages
Novell BrainShare 2002 Then What Are JSPs? Java server pages Java technology to create dynamic HTML on server-side Lets you combine static and dynamic HTML It is actually servlet code embedded on the page It is easier to use JSP when there is a lot of HTML used as it can be cumbersome to have the println statement generate HTML Behind the scenes, when a Java server page is hit, the server automatically creates, compiles, and runs servlet object Servlets can do anything that JSPs can accomplish DCB124—Introduction to Java Servlets on Jakarta Tomcat

13 Java Servlet Development Kit (JSDK)
Novell BrainShare 2002 Java Servlet Development Kit (JSDK) To use Java servlets, the JSDK is needed along with a capable servlet web engine The JSDK 2.x is available for download from DCB124—Introduction to Java Servlets on Jakarta Tomcat

14 Popular Servlet and JSP Engines to Run on Novell NetWare® Server
Novell BrainShare 2002 Popular Servlet and JSP Engines to Run on Novell NetWare® Server Jakarta Tomcat Tomcat runs on Apache server, but can be integerated with NetWare Enterprise Web Server IBM WebSphere Shipped with NetWare 5.1 GNU JSP Jetty Novell Servlet Gateway Supports only the old servlet specification 2, to be discontinued soon DCB124—Introduction to Java Servlets on Jakarta Tomcat

15 Jakarta Servlet Engine (Tomcat)
Novell BrainShare 2002 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 DCB124—Introduction to Java Servlets on Jakarta Tomcat

16 Downloading the Jakarta Software
Novell BrainShare 2002 Downloading the Jakarta Software Current and previous versions of Jakarta are available Jakarta is downloadable as source code or binary Supported platforms include NetWare, UNIX, Linux, Windows, and others DCB124—Introduction to Java Servlets on Jakarta Tomcat

17 Download the Jakarta Software
Novell BrainShare 2002 Download the Jakarta Software To get the binaries, download the following files Released Java binaries—jakarta-tomcat-3.3.zip Released NetWare Apache module—mod_jk.nlm Additional connectors nsapi_rd.nlm—enterprise server connector jni_conn.nlm—JNI connector DCB124—Introduction to Java Servlets on Jakarta Tomcat

18 Download the Jakarta Software
Novell BrainShare 2002 Download the Jakarta Software To build the source, download the following files Released source code—JAKARTA-TOMCAT-3.3-SRC.ZIP Unpack JAKARTA-TOMCAT-3.3-SRC.ZIP to an appropriate directory and read README to get additional components necessary for building Metrowerks Code Warrior 5 or later is required for building the native connectors DCB124—Introduction to Java Servlets on Jakarta Tomcat

19 Configuring Jakarta/Tomcat
Novell BrainShare 2002 Configuring Jakarta/Tomcat General configuration in tomcat\conf\server.xml General web server connector configuration in tomcat\conf\workers.properties Tomcat can auto-generate an Apache configuration file that can be included in HTTPD.CONF tomcat\conf\mod_jk.conf-auto Tomcat must be started before Apache for this file to be created and have correct information DCB124—Introduction to Java Servlets on Jakarta Tomcat

20 Adding Additional Servlets, JSPs, and Web Applications
Novell BrainShare 2002 Adding Additional Servlets, JSPs, and Web Applications Individual servlets can be placed in TOMCAT_HOME\webapps\ROOT\WEB-INF\classes Additional contexts are created under the TOMCAT_HOME\webapps directory Each directory becomes its own context Behavior for a context is defined by the WEB-INF\WEB.XML file Jakarta uses Web Application Archive (WAR) files .WAR files are automatically extracted during startup An appropriate context is created DCB124—Introduction to Java Servlets on Jakarta Tomcat

21 Hands-On Hello World Session Test

22 Hello World Example import java.io.*; import javax.servlet.*;
Novell BrainShare 2002 Hello World Example import java.io.*; import javax.servlet.*; import javax.servlet,http.*; public class HelloWorld extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); out.println(“Hello World!”); } DCB124—Introduction to Java Servlets on Jakarta Tomcat

23 Need More Help? There are a lot of online Java resources at
Novell BrainShare 2002 Need More Help? There are a lot of online Java resources at Novell Developer Kit (NDK) site at Open a incident with Novell Developer Support (free of charge for internal developers) Newsgroups on the NDK site More questions? Send me an at DCB124—Introduction to Java Servlets on Jakarta Tomcat

24


Download ppt "Introduction to Java Servlets on Jakarta Tomcat"

Similar presentations


Ads by Google