protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); response.setStatus(HttpServletResponse.SC_OK); PrintWriter out = response.getWriter(); out.println("<h1>Hello Servlet</h1>"); out.println("session=" + request.getSession(true).getId()); out.println("<br>"); out.println("<br>"); // Get an UserAgentStringParser and analyze the requesting client UserAgentStringParser parser = UADetectorServiceFactory.getOnlineUpdatingParser(); UserAgent agent = parser.parse(request.getHeader("User-Agent")); out.append("You're a <em>"); out.append(agent.getName()); out.append("</em> on <em>"); out.append(agent.getOperatingSystem().getName()); out.append("</em>!"); }
@Override public Browser getObject() throws Exception { String ua = request.getHeader("User-Agent"); ReadableUserAgent userAgent = parser.parse(ua); return new UADetectorBrowser(userAgent); }