You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Hansjörg Meuschel <hj...@gmx.de> on 2006/06/01 13:30:26 UTC
probems getting the remote ip address in a bean
Hello,
in a bean, how can I extract the IP adress of a user?
I tried
HttpServletRequest request =
(HttpServletRequest)((ServletContext)
FacesContext.getCurrentInstance().getExternalContext().getRequest());
String IP = request.getRemoteHost();
but whatever I did I got
java.lang.ClassCastException:
com.sun.faces.context.MyHttpServletRequestWrapper
Any ideas? Thanks a lot... Hans
Re: probems getting the remote ip address in a bean
Posted by Hansjörg Meuschel <hj...@gmx.de>.
Thank you Matthias!
Greets,
Hans
Matthias Wessendorf wrote:
> Why are you casting against ServletContext?
>
> HttpServletReq should be enough.
>
> com.sun.faces. is code from the RI, shipped under the sun ;-)
>
> Regards,
> Matthias
>
> On 6/1/06, Hansjörg Meuschel <hj...@gmx.de> wrote:
>
>> Hello,
>> in a bean, how can I extract the IP adress of a user?
>>
>> I tried
>>
>> HttpServletRequest request =
>> (HttpServletRequest)((ServletContext)
>> FacesContext.getCurrentInstance().getExternalContext().getRequest());
>> String IP = request.getRemoteHost();
>>
>> but whatever I did I got
>>
>> java.lang.ClassCastException:
>> com.sun.faces.context.MyHttpServletRequestWrapper
>>
>> Any ideas? Thanks a lot... Hans
>>
>
>
Re: probems getting the remote ip address in a bean
Posted by Matthias Wessendorf <ma...@apache.org>.
Why are you casting against ServletContext?
HttpServletReq should be enough.
com.sun.faces. is code from the RI, shipped under the sun ;-)
Regards,
Matthias
On 6/1/06, Hansjörg Meuschel <hj...@gmx.de> wrote:
> Hello,
> in a bean, how can I extract the IP adress of a user?
>
> I tried
>
> HttpServletRequest request =
> (HttpServletRequest)((ServletContext)
> FacesContext.getCurrentInstance().getExternalContext().getRequest());
> String IP = request.getRemoteHost();
>
> but whatever I did I got
>
> java.lang.ClassCastException:
> com.sun.faces.context.MyHttpServletRequestWrapper
>
> Any ideas? Thanks a lot... Hans
>
--
Matthias Wessendorf
Aechterhoek 18
48282 Emsdetten
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com