#!/usr/bin/sh # servletrun # # by Jeff Schmitt # Towson University # # version 0.4 July 2000 # changed to mm.mysql JDBC # # version 0.5 October 2001 # changed to SunOS # # This is an interface which allows java servlets # to be run from the cgi-bin directory # # This script will do the following: # 1) Determine if a process is listening to your port $PORT. # If so, then your servletrunner is already running. # 2) If necessary, start the servletrunner server the selected port # 3) redirect the URL of the current request to your servletrunner # Define the port where your server will listen # Port numbers should be between 10000 and 65535 # Use the same port for all of your servlets # Each user should have a unique port number PORT=65535 # Define user's servlet directory # Change this to your own servlet directory SERVLET=/usr/faculty/schmitt/servlet # Below this line should not normally require editing ########################################################## #where to find java JAVA_HOME=/usr/java #where to find java servlet development kit JSDK_HOME=/usr/faculty/schmitt/jsdk2.0 # Where to find classes used in your servlets CLASSPATH=$SERVLET:$JSDK_HOME/lib/jsdk.jar:/usr/faculty/schmitt/WWW/java/jdbc/lib/mm.mysql-2.0.2-bin.jar:/usr/faculty/schmitt/WWW/java/jdbc/lib/classes111.zip # Export this so the server process will find CLASSPATH export CLASSPATH # we need to know if the server is already running. # Get the process id of the process listening on tcp $PORT # this process id will be null if no process FUSER=`fuser $PORT/tcp 2>/dev/null` # check for null processid #if [ -z "$FUSER" ] #then # starting up the servletrunner server # # remove the old log file. # create a new log file with the current date and time /usr/local/bin/date >$SERVLET/servletrun.log # Start server and pass port number and directory information # server errors are placed in the file servletrun.log # cd $CGI_BIN $JAVA_HOME/bin/java sun.servlet.http.HttpServer \ -p $PORT \ -d $SERVLET \ >>$SERVLET/servletrun.log \ 2>>$SERVLET/servletrun.log & #fi # Generate NEW_QS with a ? prefixed to old QUERY_STRING NEW_QS= if [ -n "$QUERY_STRING" ] then NEW_QS=?$QUERY_STRING fi # Generate a header which indicates a permanent move of the # URL to a new location. The web-server will recognize this # and return a status code of 302 # This will cause the browser to repeat the request at the new # location # Note the name of the servlet the user requested is provided # by cgiwrap in the variable $PATH_INFO cat <