Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Absolute url in jsp

Tags:

url

jsp

jsf

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?

like image 699
Barun Avatar asked Jul 24 '09 03:07

Barun


People also ask

What is an absolute URL?

An absolute URL contains all the information necessary to locate a resource. A relative URL locates a resource using an absolute URL as a starting point. In effect, the "complete URL" of the target is specified by concatenating the absolute and relative URLs.

What is absolute URL explain with one example?

An absolute URL contains the entire address from the protocol (HTTPS) to the domain name (www.example.com) and includes the location within your website in your folder system (/foldernameA or /foldernameB) names within the URL. Basically, it's the full URL of the page that you link to.

How do you make an absolute URL?

If you prefix the URL with // it will be treated as an absolute one. For example: <a href="//google.com">Google</a> . Keep in mind this will use the same protocol the page is being served with (e.g. if your page's URL is https://path/to/page the resulting URL will be https://google.com ).

When would you use an absolute URL?

Linking with absolute URLs The path includes directory and file information. You must use absolute URLs when referring to links on different servers.


1 Answers

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

like image 188
Russ Avatar answered Oct 11 '22 20:10

Russ