aspose file tools*
The moose likes Servlets and the fly likes Tomcat: Problems with localhost and directories Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Tomcat: Problems with localhost and directories" Watch "Tomcat: Problems with localhost and directories" New topic
Author

Tomcat: Problems with localhost and directories

Mel Anisky
Greenhorn

Joined: Jan 27, 2012
Posts: 3
Hi everyone,

So, I finally got it to the point where if I put http://localhost:8080/ into navigation on my web browsers, I go to the Tomcat site. The one that says


If you're seeing this page via a web browser, it means you've setup Tomcat successfully. Congratulations!


But!! When I try to do something else, like http://localhost:8080/SomeDirectory/hello.html it gives me the error message
"HTTP Status 404 - /SomeDirectory/hello.html

--------------------------------------------------------------------------------

type Status report

message /SomeDirectory/hello.html

description The requested resource (/SomeDirectory/hello.html) is not available.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.35"


Yet at the same time, if I enter into the navigation bar C:\Java\tomcat\webapps\ROOT\SomeDirectory\hello.html, THAT shows up correctly!

Plus, once I'm at the main Tomcat page, nothing that isn't already online works. For instance, if I go to the left menu and click anything there besides "Tomcat Online"-- for example, Administration->Status, I get an error message:

"HTTP Status 404 - /manager/status

type Status report

message /manager/status

description The requested resource (/manager/status) is not available.
Apache Tomcat/6.0.35"

What's going on? The directory for that CAN'T be wrong, can it?

Please help!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60072
    
  65

Mel Anisky wrote:But!! When I try to do something else, like http://localhost:8080/SomeDirectory/hello.html it gives me the error message
"HTTP Status 404 - /SomeDirectory/hello.html

That means that the web app mapped to the context path SomeDirectory isn't set up correctly and isn't loading.

Yet at the same time, if I enter into the navigation bar C:\Java\tomcat\webapps\ROOT\SomeDirectory\hello.html, THAT shows up correctly!

Well, of course. The browser is simply loading the file from the file system. Tomcat isn't involved at all when you do that.

The problem is that you've mixed your web app in with the ROOT web app. The SomeDirectory folder should be in webapps, not webapps/ROOT.

Fix your mistakes and we can take the rest from there.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mel Anisky
Greenhorn

Joined: Jan 27, 2012
Posts: 3
Okay, I've done that. The html file is now at

C:\Java\tomcat\webapps\SomeDirectory

and

http://localhost:8080/SomeDirectory/Hello.html

still yields "HTTP Status 404 - /SomeDirectory/hello.html

type Status report

message /SomeDirectory/hello.html"


Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6657
    
    5

Did you check the tomcat admin page to ensure the application has been loaded ? Copying directories into tomcat will not deploy applications automatically. You need a .war file that is deployed under the folder 'webapps' or an equivalent folder.


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60072
    
  65

If the context root folder exists in webapps, Tomcat will deploy the web app if (and only if) the web app is correctly formed. A war file is not necessary.

We'll obviously need more details regarding how you deployed your web app.

But first, check the logs to see if there are any problems reported, and check the Tomcat Manager application to see if it even knows the web app exists.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6657
    
    5

A war file is not necessary.


True. Bear is referring to exploded deployments.

To clarify what I said earlier, tomcat cannot be treated like the root folder that say apache would scan to serve HTML content. Unless the folder is structured to be recognized as a web-deployment, tomcat will not recognize it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat: Problems with localhost and directories
 
Similar Threads
Servlet Deployment
first program error, something is missing
Tomcat as a server & a container, how?
Not able to access default Tomcat home page in Apache Tomcat/6.0.18
What can cause a .war file not to show/load?