Home arrow Java & J2EE arrow Page 3 - Slapping Together A JSP Development Environment

One Tomcat, Standing Alone - Java

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.

TABLE OF CONTENTS:
  1. Slapping Together A JSP Development Environment
  2. Essential Software
  3. One Tomcat, Standing Alone
  4. Connecting The Dots
  5. Same Story, Different OS
  6. Putting It In Context
  7. Making The Grade
By: icarus, (c) Melonfire
Rating: starstarstarstarstar / 4
March 05, 2001

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
The first thing you need to do is set up the JDK. Double-click the installable file you just downloaded, and let the program install itself into a convenient location on your hard drive. I'll assume you've installed it to C:\JDK\

Next, go ahead and install Apache - the default installation location of C:\PROGRAM FILES\APACHE GROUP\APACHE\ is fine - and modify the configuration file "httpd.conf" in case you need to customize its operation. You should test that the server is running by starting it up and pointing your browser to http://localhost/ - if you see an Apache test page, that means your server is up and running. You'll also see an MS-DOS window which displays a status message like this:

C:\>APACHE Apache/1.3.14 (Win32) running...

Third step: install the Tomcat Web server. Now, Tomcat comes as a single compressed file, which contains both Linux and Windows versions. You don't need to run an installation program; just unzip it to a convenient location and you're done. I used C:\TOMCAT\ as the location for my Tomcat installation.

At this point, it's time to see if the Tomcat server is working (Tomcat works independently of Apache as well). Pop open an MS-DOS window, and set up a few of the environment variables Tomcat needs to function correctly.

C:\>SET JAVA_HOME=C:\JDK C:\>SET TOMCAT_HOME=C:\TOMCAT C:\>SET PATH=%PATH%;C:\JDK\BIN

Obviously, you need to replace the locations above with the actual file paths on your system.

Once that's done, change to the Tomcat BIN\ directory and start Tomcat.

C:\TOMCAT\BIN>TOMCAT START

If all went well, you should see something like this:

Including all jars in C:\TOMCAT\LIB in your CLASSPATH. Using CLASSPATH: C:\TOMCAT\CLASSES;C:\TOMCAT\LIB\ANT.JAR;C:\TOMCAT\LIB\JAXP.JAR;C:\TOMCAT\LIB \SERVLET.JAR;C:\TOMCAT\LIB\PARSER.JAR;C:\TOMCAT\LIB\WEBSER~1.JAR;C:\TOMCAT\L IB\JASPER.JAR;C:\JDK\LIB\TOOLS.JAR Starting Tomcat in new window

You should also see a new MS-DOS window with something like this displayed in it:

2001-01-30 02:47:19 - ContextManager: Adding context Ctx( /examples ) 2001-01-30 02:47:19 - ContextManager: Adding context Ctx( /admin ) Starting tomcat. Check logs/tomcat.log for error messages 2001-01-30 02:47:20 - ContextManager: Adding context Ctx( ) 2001-01-30 02:47:20 - ContextManager: Adding context Ctx( /test ) 2001-01-30 02:47:22 - PoolTcpConnector: Starting HttpConnectionHandler on 8080 2001-01-30 02:47:22 - PoolTcpConnector: Starting Ajp12ConnectionHandler on 8007 This indicates that the Tomcat server is running on port 8080.

If, on the other hand, you got this:

Out of environment space Out of environment space Out of environment space Out of environment space Out of environment space Out of environment space Out of environment space Out of environment space Out of environment space Out of environment space Out of environment space Out of environment space Out of environment space Out of environment space Out of environment space

then there's one more thing you need to do. Close the MS-DOS prompt, move to Windows Explorer, and create a new "MS-DOS Prompt" shortcut (you can copy the one in the Start->Programs menu if you like). Right-click the shortcut, find the Memory tab, and change the "Initial Environment" memory size from "Auto" to the maximum (usually 4096 KB). Save the changes to your shortcut, use it to open up a new MS-DOS window, set the environment variables as described above, and try running Tomcat again. This time, things should work as advertised.

Quick aside: since the variables you set are destroyed each time you exit an MS-DOS session under Windows, I'd recommend that you add them to your C:\AUTOEXEC.BAT startup file so that they are permanently installed in memory. Or you could write a simple batch file which creates and sets the variables in MS-DOS before running Tomcat each time.

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 C:\TOMCAT\WEBAPPS\EXAMPLES\JSP\, containing the following JSP code:

<html> <body> <% out.println("Waiter, can I have a cup of Java, please?"); %> </body> </html>

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:

<html> <body> Waiter, can I have a cup of Java, please? </body> </html>


If it works, take a deep breath - you're halfway there! Next, you need to get Apache talking with Tomcat, so that you don't need to add the :8080 suffix each time you want to execute a JSP document.

 
 
>>> More Java & J2EE Articles          >>> More By icarus, (c) Melonfire
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

JAVA & J2EE ARTICLES

- More Java Bugs Lead to More Attacks
- Oracle's Java One Brings News, Surprises
- Oracle Patches Java Runtime Environment
- Apple Syncs Java Update with Oracle
- Spring 3.1 Java Development Framework Compat...
- Jelastic Java PaaS Availability and Pricing ...
- NetBeans 7.1 Released, Supports JavaFX 2
- SolarWinds Releases Newest Version of Java M...
- Free Monitoring Tool for Java Apps on Heroku
- Heroku Adds JCloud Platform Support, Java 7 ...
- Java SE 8 Speculation in Full Swing
- Java SE 7 Now Available
- New JVM Language and Java Reporting Tool
- Java 7 Release Update and New Eclipse Toolkit
- The Best Java Netbeans IDE Plugins

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: