Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails get war baseUrl intelligently?

My baseUrl is http://localhost:8080/whatever. On other machines, it's http://localhost/whatever.

Is there a smart way to get this information without using

<%
    String baseUrl = "http://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath()
%>

I'm trying to dynamically create some links to path parameterized rest URLS, i.e:

http://localhost:8080/a/b/${param1}/c/${param2}

If there's a better way to do this, let me know.

like image 802
Stefan Kendall Avatar asked Mar 15 '11 20:03

Stefan Kendall


1 Answers

In case you forget, isn't that was answered in the question here. Just set the grails.serverURL and grails.app.context in the configuration file of your deployed machine. Then use createLink to make the URL. Or I missed something?

like image 143
Hoàng Long Avatar answered Oct 06 '22 00:10

Hoàng Long