Java / JSP / JSTL

Index

Installation - Windows

Setup

Download the software as described in Lesson 1 - Technology, and unzip into a temporary directory.

For convinence, all software below is installed in c:\www. This is not a requirement.

Java (J2SDK)

double click on j2sdk-1_4_2_04-windows-i586-p.exe


  License
    Select Accept terms of license
    [Next]
  Custom Configration
    [Change]
    Set Destination Folder   c:\www\j2sdk1.4.2_04\
    [Ok]
    [Next]
  Browser Registration
    [Install]

  Setup Completed
    [Finish]

  

A system reboot is necessary



Tomcat

double click on jakarta-tomcat-5.0.25.exe

  Welcome
    [Next]

  License Agreement
    [I Agree]

  Choose Components
    Select Custom
    + Expand Tomcat and tick Service
    [Next]

  Choose Install Location
    [Browse]
    c:\www\tomcat
    [Next]

  Configuration
    HTTP/1.1 Port 8080
    User Name admin
    Password  admin
    [Next]


  Java Virtual Machine
    c:\www\j2sdk1.4.2_04  (dir from previous J2SDK installation)
    [Install]


  Completed
    tick Run Apache Tomcat
    [Finish]

  

NOTE: While installation allows you to start Tomcat, a reboot is usually necessary.

Using Internet Explorer or similiar Browser goto http://localhost:8080
You should see the successfull Tomcat Installation Page

Eclipse

double click on eclipse-SDK-3.0-win32.zip

unzip files to c:\www

double click on c:\www\eclipse\eclipse.exe to complete installation

Tomcat Examples Configuration

The following instructions create a custom Tomcat Environment for an example application.
This application is similar in configuration to production applications.

For reference, the following will utilise the variable CATALINA_HOME.
This will be a value like CATALINA_HOME=c:\www\tomcat (REPLACE ACCORDINGLY)

Ensure tomcat is not running.

1. Edit $CATALINA_HOME\conf\web.xml and add the following in the section providing similar syntax after corresponding *.jsp entry


      <servlet-mapping>
          <servlet-name>jsp</servlet-name>
          <url-pattern>*.htm</url-pattern>
      </servlet-mapping>
  

NOTE the .html extension is left for defining normal html files when working with http apache server applications, not applicable with tomcat.

2. Rename $CATALINA_HOME\conf\server.xml to $CATALINA_HOME\conf\server.xml.orig

3. Edit $CATALINA_HOME\conf\server.xml and include the following

<Server port="8005" shutdown="SHUTDOWN">

    <GlobalNamingResources>
        <Resource name="jdbc/example" auth="Container" type="javax.sql.DataSource"/>
        <ResourceParams name="jdbc/example">
            <parameter><name>factory</name>          <value>org.apache.commons.dbcp.BasicDataSourceFactory</value></parameter>
            <parameter><name>maxActive</name>        <value>20</value></parameter>
            <parameter><name>maxIdle</name>          <value>10</value></parameter>
            <parameter><name>maxWait</name>          <value>10000</value></parameter>
            <parameter><name>validationQuery</name>  <value>SELECT 1</value></parameter>
            <parameter><name>removeAbandoned</name>  <value>true</value></parameter>
            <parameter><name>removeAbandonedTimeout</name>  <value>120</value></parameter>
            <parameter><name>driverClassName</name>  <value>com.mysql.jdbc.Driver</value></parameter>
            <parameter><name>url</name>              <value>jdbc:mysql://localhost:3306/example?autoReconnect=true</value></parameter>
            <parameter><name>username</name>        <value>example</value></parameter>
            <parameter><name>password</name>        <value>example</value></parameter>
        </ResourceParams>

    </GlobalNamingResources>

    <Service name="example">
        <Connector port="80" />

        <Engine name="example" defaultHost="example.dev" unpackWARs="false" debug="0">

        <Host name="example.dev" appBase="webapps/example">
            <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
                prefix="example_access_log." suffix=".txt" pattern="common"/>
            <Logger className="org.apache.catalina.logger.FileLogger" directory="logs"
                prefix="example_host_log." suffix=".txt" timestamp="true"/>

            <Context path="" docBase="www/web"  debug="0" reloadable="true">
                <ResourceLink name="jdbc/example" global="jdbc/example" type="javax.sql.DataSource"/>
                <ResourceLink name="mail/Session" global="mail/Session" type="javax.mail.Session"/>
            </Context>
        </Host>
        </Engine>
    </Service>

</Server>

  

4. Rename $CATALINA_HOME\webapps to $CATALINA_HOME\webapps.orig

5. Download example.zip and unzip into $CATALINA_HOME. This will create $CATALINA_HOME\webapps\example\...

NOTE:

6. Copy necessary jar files.

The directory $CATALINA_HOME\common\lib requires the following files:

  • standard.jar, jstl.jar (these are from the Jakarta Standard Taglibs 1.1)
  • taglibs-mailer.jar (from Jakarta Taglibs Mailer libary)
  • mail.jar, activation.jar (JavaMail, Java Activation Framework, required for Jakarta Taglibs Mailer libary)
  • log4j-1.2.7.jar (Jakarta Log4J)
  • mysql-connector-java-3.0.11-stable-bin.jar (MySQL JDBC Driver)

A current version of these files are included here

In addition, $JAVA_HOME\lib\tools.jar must be copied to $CATALINA_HOME\common\lib to enable compiling of generated JSP pages. Replace tools.jar file if it exists.

$JAVA_HOME is the installation directory of Java e.g. c:\www\j2sdk_1.4.2_04

7. Update Hosts

edit c:\windows\system32\drivers\etc\hosts and add entry, leave any current lines with 127.0.0.1

  127.0.0.1	example.dev
  

Ensure you shut down all versions of Browser. Using Internet Explorer or similiar Browser goto http://example.dev

Port 80

Port 80 is what is used to on servers as the default for web pages. By default, software such as Apache HTTP Server use Port 80. Tomcat by default uses port 8080. It is possible that tomcat can be configured to use port 80, depending on your requirements.
By default, if any web sites are HTML only, or required PHP (for example), then the server must run a suitable web server (i.e. apache) on port 80, and use addition connectors to forward JSP requests to port 8080.
In addition, on Linux servers, port 80 is a privileged port, and any processes that use this port must be run by 'root'.



Next Lesson - HTML Refresher




© Copyright 2004 - ARABX Pty Ltd. All Rights Reserved