Tomcat Installation - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

Tomcat Installation

Description:

Unzip to convenient location, may be best if not inside your normal java workspace. ... Copy and unzip advjhtp1.zip file from Blackboard ... – PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 10
Provided by: cyndi8
Category:

less

Transcript and Presenter's Notes

Title: Tomcat Installation


1
Tomcat Installation
2
Installation Guide
  • Download the apache zip from Blackboard (or the
    apache web site)
  • Unzip to convenient location, may be best if not
    inside your normal java workspace.
  • Set environment variables. Go to Control Panel
    and select System. Then Advanced tab, then the
    Environment Variables button. In the CTLM, right
    click on My Computer and select Properties.
  • Add these variables for your user
  • JAVA_HOME location of your jdk, e.g.,
    c\jdk1.5.0. In the CTLM this is under
    C\Program Files\Java, which must be entered as
    c\Progra1\Java because of the spaces
  • TOMCAT_HOME not sure if this is still needed,
    but it should point to location of Tomcat
    installation, e.g.,
  • c\apache-tomcat-6.0.10
  • Copy the mysql-connector jar to
    apache-tomcat-6.0.10\lib
  • Copy and unzip advjhtp1.zip file from Blackboard
  • Place in the webapps directory under
    apache-tomcat-6.0.10
  • In Eclipse, create new project from existing
    source (so files remain in webapps directory but
    you can edit within Eclipse). Select
    advjhtp1\WEB-INF\classes.
  • Add servlet.jar as an external jar in the Build
    Path for your project.

3
Running your program
  • To start Tomcat
  • cd into apache-Tomcat-6.0.10\bin
  • startup
  • NOTE on your home computer you can install
    Tomcat as a windows service
  • To run a servlet, you must connect via Tomcat
    (you cant just open the file in the browser).
  • In your browser, type the URL http//localhost80
    80/advjhtp1/servlets/WelcomeServlet.html
  • To run the servlet without the html page, in your
    browser type http//localhost8080/advjhtp1/welco
    me1?
  • When youre done
  • cd into apache-Tomcat-6.0.10\bin
  • shutdown

4
Making Changes
  • If you make a change to a source file, you must
    shutdown and restart Tomcat. You can avoid this
    by making the following change to content.xml (in
    conf directory)
  • ltContext reloadable "true"gt
  • If you make a change to an html file you can
    simply refresh the page.

5
WEB-INF\web.xml
  • web.xml file containing a deployment descriptor
    (configuration file for web app)
  • must be in WEB-INF directory
  • lt!DOCTYPE web-app PUBLIC "-//Sun Microsystems,
    Inc.//DTD Web Application 2.2//EN"   
    "http//java.sun.com/j2ee/dtds/web-app_2_2.dtd"gt
    ltweb-appgt  lt!-- General description of the Web
    Application --gt  ltdisplay-namegt    Advanced
    Java How to Program JSP and Servlet Chapter
    Examples  lt/display-namegt  ltdescriptiongt  
     This is the Web application in which
    we demonstrate our JSP and Servlet examples.  
    lt/descriptiongt  ltservletgt    ltservlet-namegtwelc
    ome1lt/servlet-namegt      ltdescriptiongt      A
    simple servlet that handles an HTTP get request.
         lt/descriptiongt    ltservlet-classgt     
    com.deitel.advjhtp1.servlets.WelcomeServlet  
     lt/servlet-classgt  lt/servletgt 
    ltservlet-mappinggt     ltservlet-namegtwelcome1lt/ser
    vlet-namegt    lturl-patterngt/welcome1lt/url-pattern
    gt  lt/servlet-mappinggtlt/web-appgt

6
web.xml cont
  • Options for specifying URL patttern
  • Can specify server http//localhost8080/advjhtp1
    /welcome1
  • If server not specified, assumed to be the same
    as the server/port from which browser downloaded
    the Web page.
  • Can use a path mapping, which begins with / and
    ends with /, and indicates that any URL path
    that matches the pattern will be sent to the
    servlet, for example /advjhtp1/example/
  • Can use an extension mapping, which indicates
    that any request for a file with the specified
    extension will be sent to the servlet that
    handles those files, such as .jsp would send the
    request to the servlet that handles JSP requests.
  • The default servlet is specified as /, similar to
    default document of Web server (e.g., enter
    www.deitel.com into browser, receive default
    document index.html).

7
Deploying a web app
  • Set up the directory structure under webapps, for
    example advjhtp1
  • advjhtp1 web app name/context root
  • advjhtp1\servlets contains .html files
  • advjhtp1\WEB-INF deployed application, includes
    web.xml
  • advjhtp1\WEB-INF\classes root for your java
    servlet classes, also servlet.jar (unless you
    have set a path for servlet.jar)

8
Deploying, cont
  • Web applications are often deployed in Web
    application archive (WAR) files, not covered in
    this text

9
More details
  • localhost is a well-known server host name on
    most computers that support TCP/IP-based
    networking protocols such as HTTP.
  • Allows users without a network connection to see
    networking programs on the local computer.
  • 8080 is the TCP port at which Tomcat awaits
    requests. Web browsers assume TCP port 80.
  • Ports are logical locations, not physical
    hardware ports.  May also be called handshake
    point.  If the client does not specify the port,
    the service won't be found.  Ports are positive
    integers up to 65,535.  Below 1024 is usually
    reserved for system services (e.g., email, www). 
    Well-known port number describes popular services
    on the Internet, such as port 80 for Web
    servers. 
  • Tomcat is run alone for this chapter, but it
    could be integrated with a Web server such as
    Apache HTTP Server or Microsoft's IIS.
  • Some web servers support servlets directly,
    normally via a special installation procedure. 
  • When a servlet changes, Tomcat must be restarted
    (unless have hot load)
Write a Comment
User Comments (0)
About PowerShow.com