Tomcat is organized differently than Apache.  First of all Apache has a
document root, where you can put all of your php and html files in.
With tomcat, the directory structure is different.  If you want to get
started with tomcat, I suggest first creating directory under the
webapps directory of your tomcat installation.  For this example, lets
call it test.  Under test we will create a WEB-INF directory.  The
WEB-INF directory contains basically the configuration file for your web
application you will be creating in the test directory.  In the WEB-INF
folder, create a file called web.xml.  So at this point you should have
directory structure that looks like this.

Test
        WEB-INF
                web.xml


Now edit the web.xml file to contain the following:

---------------------------------------------------snip

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd";>

<web-app>
  <display-name>A test web application</display-name>
  <description>
     Your test web application
  </description>
</web-app>

---------------------------------------------------snip


Now that you have an empty web application container set up, add some
jsp files.
Keep in mind that everything under the WEB-INF directory is protected by
tomcat.  You would not want someone to browse through your configuration
now would you?

For simplicity sake, lets create a test jsp page now.  Create a file
called index.jsp directly under the directory test.  This is what your
directory structure should look like now under your test directory:

Test
        index.jsp
        WEB-INF
                web.xml



Lets add some content under your test.jsp.  We will combine some html
with java code to demonstrate how things work.

<[EMAIL PROTECTED] contentType="text/html"%> <!-- page directive -->
<[EMAIL PROTECTED] pageEncoding="UTF-8"%>    

<html>
<head><title>Your first cool page</title></head>
<body>
        <%out.println("Hello world")%> <!-- jsp code -->


</body>
</html>


Ok, make sure you have tomcat started.  On windows, go to services and
see if the service is running.  On linux, type ps -ef or ps -aux on
unix.  If it is not running, you need to start this service for your
platform.  

Next, browse to the machine where you have tomcat installed.  It might
be on the same machine your programming on.  http://localhost:8080/test/

You should see hello world now.  By default, Tomcat runs on port 8080.
You must specify the port number in your browser.  You can configure
Tomcat to run on port 80 if you wish, but that is out of the scope of
this document.  Oops, I just read you are using fedora core.  I am using
fedora core.  I have apache and tomcat set up to talk to each other
using mod_jk2.  I can send you my configuration files if you wish.  

I hope this was not too basic for you.  


Randall


 

-----Original Message-----
From: Ken Keefe [mailto:[EMAIL PROTECTED] 
Sent: Friday, November 12, 2004 1:14 PM
To: [EMAIL PROTECTED]
Subject: Please help...

I have been struggling with Tomcat for several days and I am at the end
of my rope. If I come across as irritated, I apologize in advance. 

I simply want to learn how to write JSP. I have a book and I want to
start working through it, but I am having trouble setting up a server to
serve JSP. I currently run Apache to serve HTML and PHP. Ideally, I'd
simply like Apache to start recognizing JSP and handling it
appropriately. Unfortunately that seems to not be an easy task... I have
tried using mod_jk to connect Tomcat and Apache, with no luck.

I finally gave up on trying to use Apache and I was just going to keep
them separate. Now, how do I tell Tomcat to serve my jsp files??? I
tried using the manager web program to add an application pointing to
the correct directory, it accepts the command, but nothing is added to
the application list and it doesn't serve the content like I expected it
to.

Finally I said screw it, I'll simply put my experiment files in the
document root of Tomcat and use that for now. Still no luck, it serves
up the same default stuff, even when I rename the file. 

My environment is the following: Fedora Core 2, Apache 2.0.51, Tomcat
5.5.4, JDK 1.5.0. 

Ideally I'd like to do what I talked about earlier, having Apache
"automagically" know what to do with *.jsp files. However, I'll take
what I can get!

Thank you very much in advance. I can't explain how damned aggravating
this whole thing has been.

Ken


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to