You should always create URLs by rewriting the URLs, not only so that session information can be added to the URL if necessary, but also so that the context path can be added. You must create all the URLs as absolutely the path from the top of the application, and then enable the URL rewrite handle, adding, if necessary, the context path to the front.
<c:url value="/css/site.css"/>
This will make /<context-path>/css/site.css or /<context-path>/css/site.css;jsessionid=134345434543 to the jsp file if they do not have cookies. You can also use the c: url tag to display the URL in a variable, and then use that variable several times throughout the document. Just add the var="x" attribute to the tag, and then ${x} display the URL in your document. If you are not using jsp to output your output, you will need to find the appropriate mechanism for your viewing level, but they will all have one. If you create the URL in Java code, just take a look at the source code for the c: url tag and you will see how it is done.
One embarrassment is that CSS files (and js files) are not processed, so URLs in css files and js files must be relative paths or they will break when the context path changes. Most js already use relative paths, as the library developers do not know which path you are going to install your library to. On the other hand, CSS background image images are often specified as absolute URLs, since the same CSS file can be included in html files at different levels of the file hierarchy. There is no easy solution for this, which I know differently from creating the corresponding symbolic links, so that the relative URL always works or serves to process CSS files with JSP so that the URLs can be rewritten accordingly. I'm sure there are probably filters or apache modules that you can run that will do url replacements, but then you still have to manually update your filter / module whenever you deploy a new content path.
source share