Search code examples
javalotus-noteslotus-domino

How to check browser ver/name from Lotus Notes Java agent?


Assume it's not possible. When I run agent from my browser by: http://www.xxxxxxx.com/mydb.nsf/MyAgent?OpenAgent

I want in this java MyAgent get the browser's name/ver (i.e. HTTP_User_Agent)

Is there any workaround? Thanks


Solution

  • The easiest way to do this, is to work with document context. You get a document that has all the CGI- variables as items in it. Here is example code from the designer help:

    import lotus.domino.*;
    
    public class JavaAgent extends AgentBase {
    
        public void NotesMain() {
    
            try {
              Session session = getSession();
              AgentContext agentContext = session.getAgentContext();
    
          // (Your code goes here) 
              Document doc = agentContext.getDocumentContext();
              System.out.println
            (doc.getItemValueString("http_user_agent"));
    
            } catch(Exception e) {
                e.printStackTrace();
            }
        }
    }