Meaningless Drivel is fun!*
The moose likes Tomcat and the fly likes Basic Tomcat question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Basic Tomcat question" Watch "Basic Tomcat question" New topic
Author

Basic Tomcat question

Eric Sexton
Ranch Hand

Joined: Sep 12, 2003
Posts: 133
I'm just playing with Tomcat and have it installed and running. If I enter in to my browser: "http://localhost:8080", I get the welcome page and all is good. So I create a folder under "C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\myApp". I drop an "index.html" in the "myApp" folder. So then I enter in to my browser "http://localhost:8080/myApp/index.html". I then get a 404. What am I missing? I haven't put in a web.xml or anything yet, just the html.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

im certainly no expert, and you will probly get a better answer later, but for now. what i did is i noticed their welcome page was in webapps\ROOT

so i copied their files to a new sub folder i named old index, just in case i wanted it later for some reason, and i put my stuff in ROOT

i know you dont have to do it that way, but is all the help i can give. i think to make a different folder the one http://localhost:8080 goes to you have to edit an xml file or set an environment variable
[ June 18, 2005: Message edited by: Randall Twede ]

SCJP
Visit my download page
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
So I create a folder under "C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\myApp". I drop an "index.html" in the "myApp" folder. So then I enter in to my browser "http://localhost:8080/myApp/index.html". I then get a 404. What am I missing? I haven't put in a web.xml or anything yet, just the html.


The above should have worked.

Did you remember to stop and restart Tomcat after your "myApp" was finally created?
Eric Sexton
Ranch Hand

Joined: Sep 12, 2003
Posts: 133
Yep, I have started and stopped. This is as simple as simple gets, but I don't get why it's not working.

Is there something in the setup of Tomcat that I missed? Everything under the web apps folder runs except for my stuff. Am I correct in assuming that I should be able to simply drop a folder under the 'webapps' folder and put an html file in it and it should work? I just need to enter in:"C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\anyFolderHere\index.html", correct?

As far as the way I actually start and stop, I use an icon in my task bar that I right click and say 'start service' or 'stop service'.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
I've just installed Tomcat 5.5 (Java 5.0 required) and have done what you have described. Same result 404.

Then I went into the http://localhost:8080 page and selected the link to the Tomcat Manager. There, two thirds down the page, I entered /myApp into the box labeled "Context Path (optional)". I pressed Deploy and lo and behold upon entering http://localhost/myApp I got my index.html displayed.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
But, on stopping and restarting the server, the original 404 returned However, redeploying through the Tomcat Manager page fixed that.
Eric Sexton
Ranch Hand

Joined: Sep 12, 2003
Posts: 133
Here's what I had to do. I had to deploy with the context path "/myApp" AND specify the full windows directory in the "WAR or Directory URL" like this:

"file:C:/Program Files/Apache Software Foundation/Tomcat 5.0/webapps/myApp"

So I guess this is getting is in a server config xml of some sort, but I can't find it. Anyhow, at least I know how to deploy it. Thanks for the help.
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
Another solution would be to create a WAR archive file(myApp.war) and drop it in the $CATALINA_HOME/webapps directory.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

i am becoming totally dissillusioned with both jakarta and Sun...jakarta made their products harder to use IMO, and Sun seems to be ignoring bugs and backwards compatibility issues...might as well use IIS and .net...

is my opinion that .net will win out and java will become legacy software

im not gloating...it wish it wasnt so
[ June 18, 2005: Message edited by: Randall Twede ]
Eric Sexton
Ranch Hand

Joined: Sep 12, 2003
Posts: 133
Originally posted by Craig Jackson:
Another solution would be to create a WAR archive file(myApp.war) and drop it in the $CATALINA_HOME/webapps directory.


Yeah, it's just one of those things I wanted to try and thought should easily work. Once I drop a WAR in, it's all good. At my job we deploy on WebSphere, so that's what I'm used to. I just wanted to build some stuff at home and wanted to give Tomcat a spin.
Eric Sexton
Ranch Hand

Joined: Sep 12, 2003
Posts: 133
Originally posted by Randall Twede:
i am becoming totally dissillusioned with both jakarta and Sun...jakarta made their products harder to use IMO, and Sun seems to be ignoring bugs and backwards compatibility issues...might as well use IIS and .net...

is my opinion that .net will win out and java will become legacy software

im not gloating...it wish it wasnt so

[ June 18, 2005: Message edited by: Randall Twede ]


Well, your opinion about the difficulties of Sun's and Jarkatas stuff being difficult may be true(subjectively), but J2EE has too much momentum and MS will always have people who hate them and those who don't believe their stuff is secure. The last 2 shops I've worked at had CIOs that would never let us switch to .net. I personally have nothing against it, it's just what I've seen.
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
By the way if you create a WAR file and drop it into the /webapps directory Tomcat will automatically deploy it for you, providing you did not turn that feature off. I can't remember if that is the default behavior or not. Maybe someone else can confirm?



jakarta made their products harder to use IMO, and Sun seems to be ignoring bugs and backwards compatibility issues...might as well use IIS and .net...

is my opinion that .net will win out and java will become legacy software


In my opinion, Tomcat was neither that difficult to setup nor config. But the debate over Sun vs Microsoft has grown to the proportions of Good vs Evil. But I like Java alot and I hope it is around for along time.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

i hopes so too but follow some of the links ive posted here
http://www.coderanch.com/t/360650/Servlets/java/package-javax-servlet-does-not

i have no experience with WAR files...i just wanted to move my existing web-app to new server..i have spent a week so far and it still not even close to working..

for some reason Tomcat doesnt even start now and i cant start it from start menu cause it is a service only now


i had it working for a while..just needed to recompile some servlets to reflect new directory structure
[ June 18, 2005: Message edited by: Randall Twede ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Eric Sexton:
I'm just playing with Tomcat and have it installed and running. If I enter in to my browser: "http://localhost:8080", I get the welcome page and all is good. So I create a folder under "C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\myApp". I drop an "index.html" in the "myApp" folder. So then I enter in to my browser "http://localhost:8080/myApp/index.html". I then get a 404. What am I missing? I haven't put in a web.xml or anything yet, just the html.


Eric,
In order for Tomcat to recognize your folder as w webapp, it needs to have a WEB-INF directory in it.

Try creating another directory under webapps ("myApp2"). Inside that folder, create a directory called WEB-INF.
Then put your HTML page in myApp2 and try hitting it.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Eric Sexton
Ranch Hand

Joined: Sep 12, 2003
Posts: 133
Thanks Ben! That's exactly the answer I was looking for.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

thanks ben..i suspected that but i am clueless so i wouldnt tell him to try that
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Basic Tomcat question
 
Similar Threads
can serve pages on local desktop, but not to a remote one
Problem with the Contextpath in the url
Internet requests to Tomcat
A simple servlet running on Tomcat 4.1.12
Getting Tomcat to recognize directory