Hello All,
This is post is about getting browser details (version, name ) , platform details (Operating System details) ,server and client IP addresses in Oracle ADF Application
sometimes we need these small but important details -
Code to get this information-
See the output-
Application running on Mozilla-
Application running on Chrome-
Application running on Internet Explorer-
Cheers :) Happy Learning
This is post is about getting browser details (version, name ) , platform details (Operating System details) ,server and client IP addresses in Oracle ADF Application
sometimes we need these small but important details -
Code to get 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() + "</li></ul>"); detailMsg.append("</body></html>"); FacesMessage errMsg = new FacesMessage(detailMsg.toString()); errMsg.setSeverity(FacesMessage.SEVERITY_INFO); fctx.addMessage(null, errMsg);
See the output-
Application running on Mozilla-
Application running on Chrome-
Application running on Internet Explorer-
Cheers :) Happy Learning
Share source plz
ReplyDeleteI have shared source code in blog itself , you can use same code in your ADF Application
Deletehow can i get current URL ??
ReplyDeleteYou can use this code to get url of current page
Delete//Get url of current ViewPort
String viewId = ControllerContext.getInstance().getCurrentViewPort().getViewId();
String viewUrl = ControllerContext.getInstance().getGlobalViewActivityURL(viewId);
See more at: Create shortcut of page on a button click in Oracle ADF using JShortcut library (For windows)
thnx
ReplyDeletei'm using webcenter portal. I want to popup a message for a user who is accessing my portal from specific browser version. How can i do it?
ReplyDeleteHave you tried code mentioned in blog ?
DeleteYou can put a condition to check browswer version or name and then write logic to open popup
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?
DeleteWhere 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(11.1.1.5.0 )
Build JDEVADF_11.1.1.5.0_GENERIC_110409.0025.6013
You can call this code on a button click or on page load for detailed answer post your question on OTN Forum
Deletethanks a lot to share knowledge and experience :)
ReplyDeleteCan i get Major version for Chrome instead of this WEBKit 537.36?
ReplyDeletecode not working correct.. in last it shd say chrome 29 not webkit 537
ReplyDelete