HelloWorldExample.class is the actual class that provides the servlet, HelloWorldExample.java is the java source file used to create this class. If you read the java source you'll notice it uses the LocalStrings stuff, this requires the Localstrings files in your classes directory. This servlet can be accessed via: http://jakarta.redbrick.dcu.ie/~[username]/servlet/HelloWorldExample

Jsp example:

You will also find a date.jsp file placed in your ~/public_html/ directory, since it uses a class called dates.JspCalender we need to provide it. You'll notice there's a directory called "dates" in your ~/public_html/WEB-INF/classes/ directory which provides this class. This jsp may be accessed via: http://jakarta.redbrick.dcu.ie/~[username/date.jsp

Will all this work with https ?

yes.

Can I use an index.jsp file as the default file for a directory ?

yes.

I've heard that TomCat is insecure, what's that about ?

All JSP's and servlets run as the "jakarta" user, this means that you are sharing this username with other Tomcat users. There is the potential for abuse, but not much. Access to TomCat is given on a basis of trust, breaches of trust will be viewed seriously.

I want to use a servlet/jsp to write to a file, how do I do this ?

Because servlets and jsp run as the jakarta use any files you need to write to must be writable my the jakarta user. You can use an acl to achieve this, something like:"setfacl -rm u:jakarta:6 <filename>"

What Permissions should I use ?

All of your subdirectories in WEB-INF should be 755 (or "a+rx"), all of your classes,jars and jsp's should be 644 (or "a+r").
Accessing something in http://jakarta.redbrick.dcu.ie/~[username]/WEB-INF/ doesnt seem to work, what's wrong?

The webserver has been configured to deny all attempts at accessing the WEB-INF directory.

Can I use advanced web.xml features such as URI remapping ?

Only if you use the direct form of the URL, as above. Add ":8080".

I forgot to add the classes and now my jsp/servlet wont work, how do I fix it ?

Tomcat wont try to reload your servlets or jsp's unless it has changed since the last time it accessed it. So if you forgot to add a set of classes that it needs, and it fails, just adding the classes wont be enough to fix it. You need to tell tomcat to refresh. You can do this by running: "touch [classname].class", in the same directory as the classes. After you do this, wait at least 15 seconds, and Tomcat will refresh your classes.

Running TomCat on a local Machine

Where do I start?

First off you'll need jakarta. If your in the CA labs this can be found on P\Projects\Web Servers\jakarta-tomcat-3.2.3 (This is the current version in the CA labs as of 23/2/2003).

How do I make Tomcat work?

There are a few variables you'll need to set up in order for tomcat to work. First off you'll need to set the variable JAVA_HOME to where ever your java folder is. E.g. if you were setting this up in the CA labs under Windows you'd need to type

set JAVA_HOME=C:\j2sdk1.4.0_01

You'll also need to set TOMCAT_HOME to where ever your jakarta folder is. E.g. in my CA account I have it at

H:\project\Servlet\jakarta-tomcat-3.2.3

Lastly you'll need to set up your CLASSPATH file to point to

TOMCAT_HOME\lib\servlet.jar

Is there no easier way?

I find it easier to put the above into the tomcat.bat file in jakarta-tomcat-3.2.3\bin, that way I don't have to remember to type them out everytime. Alternativly, you can just download my tomcat.bat file here

Note: This file might not work with other versions of tomcat, mine is 3.2.3. With other versions you may be best adding it youself.

How do I start Tomcat?

Now all you'll need to do is run TOMCAT_HOME\bin\startup.bat in Windows or TOMCAT_HOME\bin\startup.sh in UNIX and if you point a web browser at http://localhost:8080 You should see the default Tomcat webpage.

Anything else that will make my life easier?

There is other things you can do to files to make them more user friendly, the ones worth noting most are the servlet reloading without having to restart the server, and not having to put the :8080 at the end of localhost in your URL. To do this you can download my: server.xml and web.xml

Note: these are for the version of jakarta i'm using (3.2.3) and may not work with others.