User's IP address - Websphere

This is a discussion on User's IP address - Websphere ; Is it possible to get the user's IP address? On a servlet request there is simply the getRemoteAddr() method on the request, but this method doesn't exist on the portalrequest object....

+ Reply to Thread
Results 1 to 6 of 6

Thread: User's IP address

  1. User's IP address

    Is it possible to get the user's IP address? On a servlet request there is simply the getRemoteAddr() method on the request, but this method doesn't exist on the portalrequest object.

  2. Re: User's IP address

    well you could get it in the theme, and store it, or in the jsp of the portlet, although when reading the spec, it would seem that it is supposed to return null for the remoteaddr in the jsp



    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0

    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0



    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM

  3. Re: User's IP address

    Accessing it in the JSP doesn't seem to work either. I tried putting this in the jsp:

    <%

    out.print( request.getRemoteAddr() );

    out.print( request.getRemoteHost() );

    %>

    and it just gives me null.

  4. Re: User's IP address

    I was afraid of that after looking at the spec, I would say you could do it in the theme then and store it

    Jim




    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0

    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0



    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM


  5. Re: User's IP address

    Or you could try this...



    http://www-128.ibm.com/developerworks/forums/thread.jspa?threadID=181995



    Brian

  6. Re: User's IP address

    This solution really works!
    And this is also the way to get access to portal’s HttpServletRequest object, so for example you can retrieve GET/POST parameters of another portlet.

    HttpServletRequest sr = ((com.ibm.ws.portletcontainer.core.impl.PortletReq uestImpl)request).getHttpServletRequest();
    {
    pw.print ("getRemoteAddress(): "+sr.getRemoteAddr()+"
    ");
    pw.print ("getHeader('Host'): "+sr.getHeader("Host")+"
    ");

    Enumeration en = sr.getHeaderNames();
    while (en.hasMoreElements())
    {
    String name = (String)en.nextElement();
    pw.print(""+name+": ");
    pw.print(""+sr.getHeader(name)+"
    ");
    }
    }

+ Reply to Thread