You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by David Goodenough <da...@btconnect.com> on 2006/05/12 15:19:53 UTC

How to embed server hostname in JSP page on clustered Tomcat

I have a cluster of (currently) two Tomcat 5.5.17 instances.  I want to put a
hidden field on the pages which tells me which machine I am currently
connected to.  Reading the spec it appeared that using:-

<input type="hidden" name="host" value="${pageContext.request.serverName}" />

should work, but it would appear that all this does is take the server portion 
of the URL.

Anyone know how to do this (short of writing some Java code that is, I would 
rather use simple JSP and JSTL).

David

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to embed server hostname in JSP page on clustered Tomcat

Posted by Bill Barker <wb...@wilshire.com>.
"David Goodenough" <da...@btconnect.com> wrote in message 
news:200605121419.54620.david.goodenough@btconnect.com...
>I have a cluster of (currently) two Tomcat 5.5.17 instances.  I want to put 
>a
> hidden field on the pages which tells me which machine I am currently
> connected to.  Reading the spec it appeared that using:-
>
> <input type="hidden" name="host" value="${pageContext.request.serverName}" 
> />
>
> should work, but it would appear that all this does is take the server 
> portion
> of the URL.
>

You could try ${pageContext.request.localName}, but if you are using the 
AJP/1.3 Connector, that won't work either (it will be the ServerName of the 
Apache machine).

> Anyone know how to do this (short of writing some Java code that is, I 
> would
> rather use simple JSP and JSTL).
>
> David 




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to embed server hostname in JSP page on clustered Tomcat

Posted by Scott Purcell <pu...@charter.net>.
Not sure if you got a response to this, but this has worked for myself.



<%@ page import="java.net.InetAddress" %>

<%

    InetAddress ia = InetAddress.getLocalHost();
    out.println("<!-- hostname  " + ia.getHostName() +  " -->");
%>





----- Original Message -----
From: "David Goodenough" <da...@btconnect.com>
To: <to...@jakarta.apache.org>
Sent: Friday, May 12, 2006 8:19 AM
Subject: How to embed server hostname in JSP page on clustered Tomcat


> I have a cluster of (currently) two Tomcat 5.5.17 instances.  I want to
put a
> hidden field on the pages which tells me which machine I am currently
> connected to.  Reading the spec it appeared that using:-
>
> <input type="hidden" name="host" value="${pageContext.request.serverName}"
/>
>
> should work, but it would appear that all this does is take the server
portion
> of the URL.
>
> Anyone know how to do this (short of writing some Java code that is, I
would
> rather use simple JSP and JSTL).
>
> David
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org