Detect browser & platform information, Server and Client IP details in Oracle ADF

Sharing is Caring

Hello All,
This is post is about getting browser details ( detect browser version, name), platform details (Operating System details), server and client IP addresses in Oracle ADF Application
Sometimes we need these small but important details while working on ADF Application

Using RequestContext class we can get all details of the browser, local and remote addresses, here is the piece of code to get all this information.

        RequestContext requestCtx = RequestContext.getCurrentInstance();
        Agent agent = requestCtx.getAgent();
        String version = agent.getAgentVersion();
        String browser = agent.getAgentName();
        String platform = agent.getPlatformName();
        String platformVersion = agent.getPlatformVersion();
        FacesContext fctx = FacesContext.getCurrentInstance();
        HttpServletRequest request = (HttpServletRequest) fctx.getExternalContext().getRequest();
        StringBuilder detailMsg = new StringBuilder("<html><body><b>Browser Agent and Ip address details</b><br>");
        detailMsg.append("<ul><li><b>Browser-</b>" + browser + "</li><li><b>Version-</b>" + version +
                         "</li><li><b>Plateform-</b>" + platform + "</li>");
        detailMsg.append("<li><b>Plateform Version-</b>" + platformVersion + "</li><li><b>Server IP-</b>" +
                         request.getLocalAddr() + "</li><li><b>Client IP-</b>" + request.getRemoteAddr() +
        FacesMessage errMsg = new FacesMessage(detailMsg.toString());
        fctx.addMessage(null, errMsg);

See the output in FacesMessage

The application running on Mozilla-

Detect browser

The application running on Chrome-

Detect browser

The application running on Internet Explorer-

Detect browser

Cheers 🙂 Happy Learning

Related Posts

0 thoughts on “Detect browser & platform information, Server and Client IP details in Oracle ADF”

  1. I know the coding part but my problem is where to try that code. I'm new to adf and webcenter portal. I have created a webcenter application in my JDeveloper. It has default login page(login.jspx). In this application where do I need to insert my code?
    Where do I need to make changes? Any components or any properties need to be added?? pls guide me.
    My Jdeveloper version is 11g release 1( )
    Build JDEVADF_11.

Leave a Reply

Your email address will not be published. Required fields are marked *