Home arrow Java arrow Page 3 - Creating Your First JSP Page
JAVA

Creating Your First JSP Page


Have you ever wanted to develop JSP Web applications? This article will help you get all the tools you need installed on your computer, and walk you through the process of writing a simple application. It is excerpted from the book Beginning JSP 2 From Novice to Professional, written by Peter den Haan et al (Apress, 2004; ISBN: 1590593391).

Author Info:
By: Apress Publishing
Rating: 4 stars4 stars4 stars4 stars4 stars / 69
April 27, 2005
TABLE OF CONTENTS:
  1. · Creating Your First JSP Page
  2. · Downloading Tomcat
  3. · Trying It Out: Testing Tomcat
  4. · Creating Your First Web Application
  5. · Exploring a Brief History of Java and the Web
  6. · Java and the Web
  7. · The Java Community

print this article
SEARCH DEVARTICLES

Creating Your First JSP Page - Trying It Out: Testing Tomcat
(Page 3 of 7 )

To test that Tomcat is working, follow these steps:

  1. 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. 
  2. 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          
  3. 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.
  4. 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:

  1. 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.

  2. 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.

  3. 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 (/).
  4. 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.

blog comments powered by Disqus
JAVA ARTICLES

- Java Too Insecure, Says Microsoft Researcher
- Google Beats Oracle in Java Ruling
- Deploying Multiple Java Applets as One
- Deploying Java Applets
- Understanding Deployment Frameworks
- Database Programming in Java Using JDBC
- Extension Interfaces and SAX
- Entities, Handlers and SAX
- Advanced SAX
- Conversions and Java Print Streams
- Formatters and Java Print Streams
- Java Print Streams
- Wildcards, Arrays, and Generics in Java
- Wildcards and Generic Methods in Java
- Finishing the Project: Java Web Development ...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials