[ACCEPTED]-Building an absolute URL from a relative URL in Java-relative-url
Accepted answer
Using java.net.URL
URL baseUrl = new URL("http://www.google.com/someFolder/");
URL url = new URL(baseUrl, "../test.html");
0
How about:
String s = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/someImage.jpg";
0
Looks like you already figured out the hard 3 part, which is what host your are running 2 on. The rest is easy,
String url = host + request.getContextPath() + "/someImage.jpg";
Should give you what 1 you need.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.