Skip to Content
author's profile photo Former Member
Former Member

Get Hostname


I'm trying to read the hostname to access a file inside of my portal application:

getHostname() + request.getWebResourcePath() + "/xml/avrss.xml");
private String getHostname() {
		IURLGeneratorService generator = (IURLGeneratorService)ResourceFactory.getInstance().
		IHierarchicalUri absUri = generator.getAbsoluteUri(PathKey.CONTENT_ACCESS_PATH);
		return splitAfterPort(absUri.toString());
	catch(Exception e){
		return "null;" + e.getMessage();
private String splitAfterPort(String str) {
	int start = 0;
	if (str.startsWith("http")) {
		start = 7;
	return str.substring(0, str.indexOf('/', str.indexOf(':', start)));

this works fine on our development system. But on our productive system with two servers and four dialog instances (this is the only difference), the hostname is empty (returned value is http:/irj/portalapps/xyzproject/xml/avrss.xml).

How can I get the hostname in all cases?

thank you

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Oct 01, 2010 at 03:54 PM


    please check in the productive system, if the IURLGeneratorService is set up with the correct name.



    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.