Creating Your First JSP Page - Trying It Out: Testing Tomcat (Page 3 of 7 ) To test that Tomcat is working, follow these steps: On Windows, the installer created a group in your Start menu, probably called Apache Tomcat 5.0. To run Tomcat, select the Start Tomcat item in this menu. Alternately, if you prefer the Windows command line, you can execute the following command:
> %CATALINA_HOME%\bin\startup
However, because you’ve added %CATALINA_HOME%\bin to the path, you can just type startup, and it’ll work.
On Linux, you can start Tomcat by executing the following script:
/usr/local/java/tomcat50/startup.sh
Because you’ve added Tomcat to the PATH variable, you can simply type startup.sh.
Once Tomcat is up and running, open your favorite Web browser and navigate to http://localhost:8080. You should see a page something like the one shown in Figure 1-2. Figure 1-2. Tomcat's default welcome page Scroll to the Examples box on the left side, click the JSP Examples link, and try out a couple of the sample programs to verify that everything is working properly. If you can’t get the examples to work, double-check that you’ve correctly followed the previous instructions.
At some point, you’ll want to shut Tomcat down. On Windows, you can do this by clicking the Stop Tomcat item in the Start menu. The command-line version of this is%CATALINA_HOME%\bin\shutdown, or just shutdown. Normally, you should avoid simply closing the Tomcat window because that may result in losing data.
On Linux, execute the script shutdown.sh.
How It Works: When Things Go Wrong If Tomcat didn’t start like it was supposed to, try the following suggestions to figure out where things went wrong: - On Windows, open a command prompt (look for Command Prompt in the Start menu or type cmd or command in the Run option given on the Start menu). Type the command cd %CATALINA_HOME%. On Linux, type cd $CATALINA_HOME. Verify that you’re now in the directory where you installed Tomcat. If not, repeat the step for creating that environment variable in the previous “Configuring Your Environment” section.
- Repeat the same process using %JAVA_HOME% or $JAVA_HOME. If you’re not in the correct location, make sure you set up this variable correctly in the “Configuring Your Environment” section.
- From the Windows command line, type java and press Enter. If you see a message starting with “‘java’ is not recognized as,” try typing %JAVA_HOME%\bin\java and pressing Enter. If that still produces the same error message, it indicates that Java wasn’t properly installed for some reason.
Verify that you properly followed the instructions for installing Java, and check the http://java.sun.com Web site for help. If the first command failed but the second one succeeded, repeat the instructions for setting the PATH variable in the “Configuring Your Environment” section.
The same applies to Linux users, but you’ll need to use $JAVA_HOME in place of %JAVA_HOME% in the previous instructions. Also note that Windows uses a backslash (\) for its paths whereas Linux uses a forward slash (/).
- If you’ve made it this far, check and see if Tomcat was properly installed at the path you selected. If not, reinstall it, referring to the http://jakarta.apache.org/tomcat Web site for any special guidance.
Next: Creating Your First Web Application >>
More Java Articles More By Apress Publishing | This article is excerpted from Beginning JSP 2: From Novice to Professional, by Peter den Haan et al (Apress, 2004; ISBN: 1590593391). Check it out at your favorite bookstore. Buy this book now.
|
| |