myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Robinson" <andrew.rw.robin...@gmail.com>
Subject Re: how to get the server name inside of a backing bean?
Date Tue, 24 Oct 2006 14:32:33 GMT
I have used relative links in my CSS and javascript to address the
issue. Since the CSS URLs are relative to the CSS file, not the page
including them, relative should work just fine (as long as you don't
move things around)

On 10/24/06, Ludovic Robinot <lrobinot@free.fr> wrote:
> Andrew Robinson a dit le 10/24/2006 06:50 AM:
> > 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}
>
> I have a similar question. How to solve the same problem in external
> files like the css files containing url()?
>
> Do we have to use EL in CSS or javascript files and served them through jsf?
>
> --
> Ludovic
>

Mime
View raw message