tags:

views:

537

answers:

2

Hi,

While including css, js and images in my jsps I am facing a problem resolving relative urls. The urls get changed on refreshing the page or clicking the back button. I suppose one solution to the problem would be to include external files by using absolute urls. But I can't find out how to use a reference to the relative url and use it. Can anyone please help me on this?

+3  A: 

Is this what you're looking for? ${pageContext.servletContext.contextPath}

... in your jsp:

<link rel="stylesheet" href="${pageContext.servletContext.contextPath}/css/page.css"   media="all"    type="text/css" />
vector
Thanks...this really solved my problem..
Barun
+2  A: 

This would also work and may be easier to read and has some extra benefits such as proper escaping and optional inclusion of parameters

<link href="<c:url value="/style/style.css"/>" rel="stylesheet" type="text/css" />

Russ