Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Tomcat and the fly likes Problem finding resources for default web app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Problem finding resources for default web app" Watch "Problem finding resources for default web app" New topic
Author

Problem finding resources for default web app

Lonnie Lewis
Greenhorn

Joined: Mar 30, 2009
Posts: 8
I'm having a problem that I'm sure has been answered at least 100 times, but I just can't find the answer

I have deployed a web application and have configured the ROOT.xml file to use it as the default:



That all works fine, my application come up using either http://www.fubar.foo/myApp, or http://www.fubar.foo. The problem is if I access via http://www.fubar.foo, it doesn't find either my CSS or javascript files. Right now I'm including them like:



What am I doing wrong?

Thanks
Lonnie


Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63052
    
  69

You are using page-relative addressing. Bad idea. Very bad. As you've discovered.

Use server-relative addressing (starts with context path). There's a JSP FAQ in this subject.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Lonnie Lewis
Greenhorn

Joined: Mar 30, 2009
Posts: 8
Bear Bibeault wrote:You are using page-relative addressing. Bad idea. Very bad. As you've discovered.

Use server-relative addressing (starts with context path). There's a JSP FAQ in this subject.


Thanks for the reply. I should have added a little more detail. I started out with:



Which is, I think, the correct way to use context paths. Is this right? If so, what else could be the problem?

When trying to fix the problem, I took out the context pathing stuff which didn't seem to have any affect on the problem.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63052
    
  69

Did you check the JSP FAQ? The answer is there, waiting for you.
Lonnie Lewis
Greenhorn

Joined: Mar 30, 2009
Posts: 8
Bear Bibeault wrote:Did you check the JSP FAQ? The answer is there, waiting for you.


Again, thanks for the reply. Yes, I did look at the FAQ, if this is the one your are talking about: http://faq.javaranch.com/java/ResourceUrlProblems, along with others and they seem to point to the solution that I started out with.



(emphasis on ${request.contextPath})

It seems like my problem is because I'm accessing the application via the default (ROOT.xml). There looks like there was a similar problem here http://www.coderanch.com/t/414451/JSP/java/fail-include-file-from-upper#1827169

If you are referring to a different FAQ article, please let me know.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63052
    
  69

Lonnie Lewis wrote:(emphasis on ${request.contextPath})

Yes, that's where the emphasis belongs. Because it's wrong.

You may need to read the FAQ again.
 
wood burning stoves
 
subject: Problem finding resources for default web app
 
It's not a secret anymore!