public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=utf-8"); String agent = request.getHeader("User-Agent"); if (agent.contains("Trident")) { response.getWriter().print("不准使用这么垃圾的浏览器"); } else if (agent.contains("Chrome")) { response.getWriter().print("您当前使用的浏览器是谷歌"); } else if (agent.contains("Firefox")) { response.getWriter().print("您当前使用的浏览器是火狐"); } else { response.getWriter().print("其他浏览器"); } }