//获取系统时间
Date nowTime=new Date();
req.setAttribute("systime",nowTime);
Object obj=req.getAttribute("systime");
resp.setContentType("text/html;charset=UTF-8");
PrintWriter out = resp.getWriter();
out.print("req域当中取的系统当前时间"+obj);
//这个方法使用比较多。(动态获取应用的根路径)
String contextPath = req.getContextPath();
System.out.println("应用的根路径"+contextPath);
//获取请求方式
String method = req.getMethod();
System.out.println(method);
//获取请求URI
String requestURI = req.getRequestURI();
System.out.println(requestURI);
//获取servlet path(不加项目名)
String servletPath = req.getServletPath();
System.out.println(servletPath);