Presentation is loading. Please wait.

Presentation is loading. Please wait.

Object-Oriented Enterprise Application Development Tomcat 3.2 Configuration Last Updated: 03/30/2001.

Similar presentations


Presentation on theme: "Object-Oriented Enterprise Application Development Tomcat 3.2 Configuration Last Updated: 03/30/2001."— Presentation transcript:

1 Object-Oriented Enterprise Application Development Tomcat 3.2 Configuration Last Updated: 03/30/2001

2 Topics This Tomcat overview examines: Creating a new server Starting and stopping the server The web.xml file Installing web components Running servlets and JavaServer Pages

3 Application Servers

4 Functions A web server is software that provides the ability to reference both static and dynamic web resources. It is really designed to be a repository for all web-based business logic. This software abstracts the routine mechanics of executing this components so that we don't have to do it.

5 Servlet Engines To execute a servlet or JavaServer Page, you must have an appropriate engine. The engine is the software that handles requests for a particular type of resource. A servlet engine handles servlet requests. A JSP engine handles requests for JavaServer Pages.

6 Web Connectors When a web server receives a request for static content such as an HTML document, it handles the request itself. When a request for dynamic content, such as a servlet, is received, the web server must hand that request off to the web container for processing. This is the job of the web connector.

7 Jakarta - Tomcat Jakarta-Tomcat is the servlet and JavaServer Pages engine available from the Apache Group. http://jakarta.apache.org/tomcat Tomcat is small, installs quickly, and is free. The current version is Tomcat 3.2. For this class, Tomcat will be acting as both a web and application server.

8 Server Configuration

9 Tomcat Root The directory where you installed Tomcat is called the. For instance: c:\apache\jakarta-tomcat We'll use the as our point of reference for all Tomcat configuration and installation issues.

10 Document Root Change to the webapps directory under the. Create a new directory for this class called se452. This new directory is the for the new application.

11 Directory Structure Within your, create the following directory structure: /WEB-INF /WEB-INF/classes /WEB-INF/lib All directory and file names are case- sensitive.

12 Server Configuration (1 of 2) Once you've chosen a for your application, you need to make Tomcat aware of it. If any part of your configuration is incorrect, Tomcat will fail to start. Tomcat records the problem in the /logs directory.

13 Server Configuration (2 of 2) All tomcat configuration information is stored in /conf. Edit the server.xml file. Add a new Context entry to the file: <Context path="/se452" docBase="webapps/se452" debug="9" reloadable="true" trusted="false"

14 Servlet Installation

15 Purpose Before we can execute a servlet, it must be installed under control of the application server. This involves two (2) steps: Installing the servlet's class files Modifying the application's web.xml file.

16 Deploying Servlets (1 of 2) Servlets are just Java classes. The servlet.class file is copied to the WEB-INF/classes directory. If you're using packages, make sure to install them in the WEB-INF/classes directory.

17 Deploying Servlets (2 of 2) We need to make Tomcat aware of the fact that a new servlet has been deployed to the server. This is done through the web.xml file. The web.xml file contains important configuration information relevant to the application.

18 Modifying the web.xml File Once the servlet class files have been installed on the server we need to update the web.xml file. This file allows us to map "pretty" names that are seen by the application's clients to "ugly" names used internally. This file uses an XML format to specify the servlet properties.

19 Modifying web.xml (1 of 2) We create a new servlet entry in the web.xml file for each servlet: howdy HelloWorld

20 Modifying web.xml (2 of 2) We next provide a translation from URLs to the servlet name slide: howdy /greetings

21 JSP Installation

22 Purpose Before we can execute a JSP, it must be installed under control of the application server. In contrast to servlets, this really only involves a single step: Install the JSP files anywhere you would install a static HTML document. Any embedded Java classes referenced by the JSP must exist in the server's CLASSPATH.

23 Custom Tags (1 of 2) To deploy a custom tag, you need to install the two components: Tag library descriptor Tag class Each of these elements goes in a separate location.

24 Custom Tags (2 of 2) The tag library descriptor can go in the same directory as the HTML and JSP files. This is typically the. The tag class package is installed within the /WEB- INF/classes directory.

25 Changing JavaServer Pages (1 of 3) Tomcat can generally tell if a JSP has changed and will recompile the class. However, this process is not guaranteed to be accurate. You may find yourself making changes to a JSP and those changes not appearing in your output.

26 Changing JavaServer Pages (2 of 3) There is a directory called work within your. This directory contains all of the translated and compiled JSPs. Within this directory there is a directory for each defined to the Tomcat server.

27 Changing JavaServer Pages (3 of 3) Make sure that Tomcat has been stopped. Change to the directory that holds your compiled JSPs. Delete any of the.java or.class files as needed. Restart Tomcat.

28 Tomcat Administration

29 Bouncing the Server Whenever you make configuration changes to Tomcat you should "bounce" the server. "Bouncing" is a term we use to describe the process of stopping and then immediately restarting a server. For tomcat this means issuing the shutdown and startup commands located in the /bin directory.

30 Executing Servlets

31 Executing a Servlet (1 of 2) To execute a servlet, you need to issue a request to Tomcat via a client. The most obvious client to use is a web browser. By default Tomcat listens for requests on port 8080. This value can be changed, but for this class 8080 should be fine.

32 Executing a Servlet (2 of 2) To execute the HelloWorld servlet we just entered into the web.xml file, use the following URI: http://localhost:8080/se452/greetings http://localhost:8080/se452/servlet/howdy http://localhost:8080/se452/servlet/HelloWorld This works because of the translations established in the web.xml file.

33 Initialization Parameters

34 Purpose Sometimes we want a servlet to initialize itself when it's first loaded by the servlet engine. For instance we might want to load some configuration data before allowing the servlet to handle client requests. This approach can be useful for testing your code without writing HTML pages or complex URLs.

35 Modifying web.xml Initialization parameters are associated with their servlet within the web.xml file: howdy … … parm1 value1

36 Changing Initialization Parameters If you change the name and/or value of an initialization parameter you'll need to bounce the server. Bouncing the server forces it to re-load the server.xml and web.xml files.

37 Executing JSPs

38 Executing a JSP (1 of 2) To execute a JSP, you need to issue a request to Tomcat via a client. The most obvious client to use is a web browser. By default Tomcat listens for requests on port 8080. This value can be changed, but for this class 8080 should be fine.

39 Executing a JSP (2 of 2) To execute the HelloWorld JSP, use the following URI: http://localhost:8080/se452/HelloWorld.jsp Unlike servlets, there are no intermediate translations from logical names to physical JSP files.

40 Resources Tomcat Documentation You should plan on spending some time reading the configuration and user's guides. Most of the problems that you'll experience can have their solutions traced directly back to one of these two guides.


Download ppt "Object-Oriented Enterprise Application Development Tomcat 3.2 Configuration Last Updated: 03/30/2001."

Similar presentations


Ads by Google