• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Make Tomcat go

 
Trailboss
Posts: 24069
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
paul wheaton
Trailboss
Posts: 24069
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doing it the way you're doing it, are you just seeing the text of the file itself?
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24069
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24069
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
reply
    Bookmark Topic Watch Topic
  • New Topic