myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jim the Standing Bear" <standingb...@gmail.com>
Subject Re: how to get the server name inside of a backing bean?
Date Tue, 24 Oct 2006 19:47:33 GMT
Thanks, Andrew! Yeah, the relative link works like a charm.

On 10/24/06, Andrew Robinson <andrew.rw.robinson@gmail.com> wrote:
> Why not just use a relative link with a leading slash '/'? Without the
> context root, the link would be above the projects, so you can just
> put the context root of the other servlet in the URL.
>
> As for getting the server name, there is no "one" server name, as the
> URL of a web server is not always the name of the computer hosting the
> web site. You can however get the URL of the server that the user
> requested for the current request/response. The HTTP header for this
> is 'SERVER_NAME'. This variable is also accessible through the
> HttpServletRequest.getServerName() variable.
>
> Assuming you are in a servlet environment (looks like you are), you
> would get the variable like so:
>
> ((HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest()).getServerName()
>
> In EL:
>
> #{facesContext.externalContext.request.serverName}
>
> -Andrew
>
> On 10/23/06, Jim the Standing Bear <standingbear@gmail.com> wrote:
> > Hi everyone,
> >
> > I am working on a JSF project, and one commandLink would refer to a
> > different project (a servlet) on the same tomcat server.  My question
> > is, how can I obtain the name of the server from a backing bean, so
> > that I can dynamically populate the commandLink no matter where the
> > war is deployed?  Because my JSF project would always have to use the
> > servlet that coexists on the same server, so hardcoding the servername
> > into the commandLink value is not an option for real deployment.
> >
> > I know in servlet there is a way to do that, and even in JSP...  but
> > now I need to do that in JSF backing bean.  Please help. Thanks!
> >
> > Jim
> >
> >
> >
> > --
> > --------------------------------------
> > Standing Bear Has Spoken
> > --------------------------------------
> >
>


-- 
--------------------------------------
Standing Bear Has Spoken
--------------------------------------

Mime
View raw message