Question

I'm jumping into an existing JSP project, using eclipse spring, tomcat 6.

Our project currently has the URL: http:localhost/path1 as its base.

In my index.jsp, when I try to reference .css & .js using: "/css/my.css"

It doesn't append the "/path1" before it, how do I set it up to automatically add that?

And I can't use a variables as I want to these fixed paths inside my .css file to reference images.

I don't want to explicitly type it in as that "path1" will change later.

Thanks!

Was it helpful?

Solution

Context path need to be included at the beginning of the url. If you don't want to hardcode the context path, you may use the following

<%@ include file="${pageContext.request.contextPath}/css/My.css" %>

OTHER TIPS

Yes, use <c:url value="/css/file1.css" /> - this will append the context.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top