File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Make Tomcat go Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Make Tomcat go" Watch "Make Tomcat go" New topic
Author

Make Tomcat go

paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20690
    ∞

On my computer I have a directory C:\www\richsoil
I installed tomcat and can bring up the default tomcat page.
I would like to be able to bring up a browser window and see the jsp at c:\www\richsoil\index.jsp
The last time I ever used tomcat was three years ago, so I'm grateful for the new web interface. But I must be missing an important step.
Any help?


permaculture Wood Burning Stoves 2.0 - 4-DVD set
paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20690
    ∞

All I wanna do is develop JSP's locally. I read through docs and stuff and there must be some simple thing that I don't understand in the tomcat configuration.
Surely, somebody can see where I'm being a dope and can point it out.
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

Doing it the way you're doing it, are you just seeing the text of the file itself?


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

I know you could configure Tomcat to use that directory. But Tomcat always had their Webapps directory for you to put all your web applications.
You could place your jsp file in the webapps directory. Make whatever directory structure you need or want. Remember to follow Sun's directory guidelines for Web application directories.
Mainly .html and jsp files in the web applications root directory. war files in the web-inf/lib class files in web-inf/classes and the web.xml in the WEB-INF/ directory,
So you could have
TOMCAT_HOME/webapps/richsoil directory
your .jsp file goes in this directory
now you can use http://localhost:8080/richsoil/index.jsp
for the other files, if you had them then you would create a WEB-INF directory from this directory, etc.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
If you are dead set on using that path, I believe in the server.xml file you need to create a context for you web app that points to the directory that is the "root".
http://jakarta.apache.org/tomcat/tomcat-4.0-doc/config/context.html
If I was at home, I could give you a concrete example because I rarely put things in the default directory anymore, but the mind is blanking.
paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20690
    ∞

So my error is in thinking that I can tell tomcat "if somebody wants 'richsoil', go get that stuff from that directory over there." Tomcat does not do that. Correct?
So I gotta move my development directory out of "C:\www" and into "C:\Program Files\Apache Group\Tomcat 4.1\webapps". Ug.
Is there a way to tell Windows XP "if somebody looks for C:\Program Files\Apache Group\Tomcat 4.1\webapps\richsoil" you can find that stuff in C:\www\richsoil" ??
paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20690
    ∞

Jason,
So if I wanna change the root, then I might sacrifice the tomcat admin page and their other stuff, right? There is no way to say "localhost" goes to the tomcat junk and "localhost/richsoil" goes to the other stuff. Or even better: "localhost:8080" goes to the tomcat stuff and "localhost:80" goes to my richsoil stuff. I would really like to get this to the point where I could be doing javaranch stuff on here too. So maybe localhost:80 could be javaranch and localhost:8000 could be richsoil ...
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
You configure a Context for a specific web application, not for the server itself (thought that may be possible, not sure).
So you could have 3 or 4 different web applications, each in a completely directory structure, and still have Tomcat's initial admin page and all that.
I'll search the web for a bit to see if I can get you an example.
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
Found a decent article that may help
http://www.onjava.com/pub/a/onjava/2002/07/31/tomcat.html
Notice the element
<Context path="/examples" docBase="examples" debug="0"
reloadable="true">
That says that when going to localhost:8080/examples, Tomcat will look in the TOMCAT_HOME/Webapps/examples directory. You wanted to have a completely different path, you can use an absolute path and specify something like
<Context path="/examples" docBase="D:/wwww/examples" debug="0"
reloadable="true">
The path attribute specifies the web app, docBase specifies the directory.
So I think you should be able to do something like
<Context path="/richsoil" docBase="D:/www/richsoil" debug="0"
reloadable="true">
Under the richsoil directory, you'd still need the standard web-app directory structure, and corresponding web.xml file.
[ September 19, 2003: Message edited by: jason adam ]
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

Yes Jason is right, you can change the server.xml to specify directories for your Web apps without having to use Tomcats directories given to you free of charge.
Mark
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6


The above was taken from my server.xml which is in the TOMCAT_HOME\conf directory.
Context path="/examples" docBase="examples"

this looks like the place where you can put a complete path. It probably takes relative and complete paths. In the example above it is obviously a relative path, but you should be able to put in your "C:\directory"
Mark
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
According to the documentation I read for the docBase attribute:
You may specify an absolute pathname for this directory or WAR file, or a pathname that is relative to the appBase directory of the owning Host.
[ September 19, 2003: Message edited by: jason adam ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Make Tomcat go