[Logo]
Forums Register Login
Problem finding resources for default web app
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


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.
 

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.
Did you check the JSP FAQ? The answer is there, waiting for you.
 

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.

 

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.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards


This thread has been viewed 1315 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jan 19, 2018 04:58:46.