How to set relative URL in servlet jsp

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.



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" %>

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

Need Your Help

What do you think of Model-driven Software Development?

model-driven-development mdsd

I'm really interested to hear what you think about Model-driven Software Development for Java and/or .NET.