Deploying a JSP development environment on your workstation cantest even the strongest of wills, since it requires the peacefulco-existence and cooperation of a number of complex software packages. Thistutorial guides you through the process of getting Apache, JServ and Tomcatconfigured, alerts you to some of the problems you're likely to encounter,and briefly discusses Tomcat contexts and JSP-mySQL connections. Coversboth Windows and Linux.
If you're using Linux, the procedure is almost identical. First, install the Linux version of the JDK to a directory of your choice (I used /usr/local/jdk/) and then follow that up by installing the Tomcat server (/usr/local/tomcat/). You shouldn't usually need to install Apache, since that comes standard on most Linux distros - however, you should check and ensure that the version you have supports loadable modules. You can verify this by typing
$ /usr/local/apache/bin/httpd -l (assuming that Apache has been installed to /usr/local/apache/)
and viewing the resulting output - if you see the line
in the list of compiled-in modules, you're good to go. If
not, you'll need to recompile your Apache server with support for loadable modules.
You first need to test whether the Tomcat server is working in stand-alone mode. First set the environment variables JAVA_HOME and TOMCAT_HOME to the appropriate locations, like this:
And then run Tomcat using the shell script in the
$ /usr/local/tomcat/bin/tomcat.sh start
Tomcat should start up, displaying messages similar to
the ones above.
In order to test your Tomcat installation, point your browser to http://localhost:8080/ and try browsing through the various JSP examples available on the default page at http://localhost:8080/examples/jsp/
Alternatively, you could create a simple JSP file called "hello.jsp" in the directory /usr/local/tomcat/webapps/examples/jsp/, containing the following JSP code:
out.println("Waiter, can I have a cup of Java, please?");
And now, when you point your browser to
http://localhost:8080/examples/jsp/hello.jsp, you should be presented with a page which looks like this:
Waiter, can I have a cup of Java, please?
Next, you have to set up Apache to communicate with
Tomcat via mod_jserv. Install the mod_jserv.so module that you downloaded (you can either get the source and compile it, or use one of the pre-built RPMs) and then edit Apache's "httpd.conf" file to insert the following lines into it:
LoadModule jserv_module modules/mod_jserv.so
If you're using an RPM, this may be done for you
And then add the following line to the end of "httpd.conf":
Shut down Apache, start Tomcat, and then restart Apache.
If all has gone well, you should now be able to browse to http://localhost/examples/jsp/hello.jsp and view the JSP document correctly.