HOME - Recent Changes - Search:

Academic Work


Personal

* pot de départ


dblp


(:twitter:)

-----

[ edit | logout ]
[ help | sandbox | passwd ]

Figure out the URL and the port of the Tomcat server

#############################

Problem

In Liferay I have some tabs. In a portlet I want to add a link which would send the user to another tab. Here I should use a full URL like http://localhost:8081/web/guest/tab2. It's OK on my machine but if I put it on a server, the address and port will change. Thus, the string localhost:8081 shouldn't be hardcoded. How to figure it out dynamically?

Solution

Use the renderRequest object which is available in your JSPs:

Example:

/**
* Ex.: http://localhost:8081
*/
public final static String getLiferayUrl(RenderRequest request) {
    return "http://" + request.getServerName() + ":" + request.getServerPort();
}
Cloud City


anime | bash | blogs | bsd | c/c++ | c64 | calc | comics | convert | cube | del.icio.us | digg | east | eBooks | egeszseg | elite | firefox | flash | fun | games | gimp | google | groovy | hardware | hit&run | howto | java | javascript | knife | lang | latex | liferay | linux | lovecraft | magyar | maths | movies | music | p2p | perl | pdf | photoshop | php | pmwiki | prog | python | radio | recept | rts | scala | scene | sci-fi | scripting | security | shell | space | súlyos | telephone | torrente | translate | ubuntu | vim | wallpapers | webutils | wikis | windows


Blogs and Dev.

* Ubuntu Incident
* Python Adventures
* me @ GitHub


Places

Debrecen | France | Hungary | Montreal | Nancy


Notes

full circle | km


Hobby Projects

* Jabba's Codes
* PmWiki
* Firefox
* PHP
* JavaScript
* Scriptorium
* Tutorials
* me @ GitHub


Quick Links


[ edit ]

View - Edit - History - Attach - Print *** Report - Recent Changes - Search
Page last modified on 2010 April 08, 22:23