notice "$MENUTRUE" "Setting up Jakarta...\n"

if [ -z $FAST ]; then
 IsYNLoop " Do you wish to edit Jakarta's default installation path of \"$JAKARTA_HOME\"?"
  case "$?" in
   $NO)
    ;;
   $YES)
    echo
    echo
    say "Enter the installation path for Jakarta now [$JAKARTA_HOME]: "
    read JAKARTA_HOME2
     if [ -z "$JAKARTA_HOME2" ]; then
      echo "No path specified, defaulting to $JAKARTA_HOME."
     else
      JAKARTA_HOME=$JAKARTA_HOME2
     fi
    notice "$MENUTRUE" " Jakarta's install path specified ($JAKARTA_HOME), continuing with configuration...\n"
    HitAnyKey
    ;;
   esac


 IsYNLoop " Do you wish to edit the Java installation path of \"$JAVA_HOME\"?"
  case "$?" in
   $NO)
    ;;
   $YES)
    echo
    echo
    say "Enter the installation path for Java now [$JAVA_HOME]: "
    read JAVA_HOME2
     if [ -z "$JAVA_HOME2" ]; then
      echo "No path specified, defaulting to $JAVA_HOME."
     else
      JAVA_HOME=$JAVA_HOME2
     fi
    notice "$MENUTRUE" " Java's install path specified ($JAVA_HOME), continuing with configuration...\n"
    HitAnyKey
    ;;
   esac
fi



if [ ! -x $JAKARTA_HOME/build/tomcat/bin/startup.sh ]; then

 if [ ! -d $JAKARTA_HOME ]; then mkdir $JAKARTA_HOME; fi
  . $root/bin/jakarta-j2sdk
  export PATH=$JAVA_HOME/bin:$PATH
  . $root/bin/jakarta-jaxp
  . $root/bin/jakarta-jsse
  . $root/bin/jakarta-ant
  . $root/bin/jakarta-servletapi
  . $root/bin/jakarta-tomcat
 fi

echo "
# ---------------------------------------
#   Apache Jakarta-Tomcat
# ---------------------------------------
# Please read:
# http://jakarta.apache.org/tomcat/tomcat-3.2-doc/uguide/tomcat_ug.html
# ---------------------------------------
# (1) Loading the jserv module that serves as Tomcat's apache adapter.
#  (1b) this will work after you run \"apxs -c -o mod_jserv.so *.c\"
#       in \"$JAKARTA_HOME/jakarta-tomcat/src/native/apache/jserv\".
#       Make sure \"apxs\" is in your path!
#Enable this after following Step 1b!
#LoadModule jserv_module libexec/mod_jserv.so

# (1a) Module dependent configuration.
<IfModule mod_jserv.c>

# The following two lines register the JSP type with
# Apache and instruct it to have all JSP requests
# handled by the jserv-servlet handler.
AddType      text/jsp .jsp
AddHandler   jserv-servlet .jsp

# (2) Meaning, Apache will not try to start Tomcat.
ApJServManual on
# (2a) Meaning, secure communication is off
ApJServSecretKey DISABLED
# (2b) Meaning, when virtual hosts are used, copy the mount
#      points from the base server
ApJServMountCopy on
# (2c) Log level for the jserv module.
ApJServLogLevel notice

# (3) Meaning, the default communication protocol is ajpv12
ApJServDefaultProtocol ajpv12
# (3a) Default location for the Tomcat connectors.
# Located on the same host and on port 8007
ApJServDefaultHost localhost
ApJServDefaultPort 8007

# (4)
# ~~ ATB note: change this and enable it ~~
#ApJServMount /examples /root

# Full URL mount
# ApJServMount /examples ajpv12://hostname:port/root
</IfModule>
" >> $root/apache_$APACHE/conf/httpd.conf-dist

# set a script to easily start tomcat
echo "
#!/bin/sh
export PATH=\"${JAVA_HOME}/bin:$PATH\"
export TOMCAT_HOME=$LOCAL_PATH/jakarta/dist/tomcat
cd \$TOMCAT_HOME
./bin/startup.sh
" > $JAKARTA_HOME/start.sh

chmod a+x $JAKARTA_HOME/start.sh




echo_line
echo "
start Jakarta Tomcat by running...

\"$JAKARTA_HOME/start.sh\"

-----
to test...
lynx http://localhost:8080
-----

to shutdown...
\"cd $JAKARTA_HOME/dist/tomcat\"
\"./bin/shutdown.sh\"
"
echo_line
if [ -z $FAST ]; then
 HitAnyKey
fi

cd $root
notice "$MENUTRUE" "Jakarta setup!\n"

