package web;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class RequestInfo extends HttpServlet {
public void service(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{
//获取所有消息头信息
Enumeration e = request.getHeaderNames();
while(e.hasMoreElements()){
//Enumeration
String headerName = e.nextElement().toString();
System.out.println(headerName+":"+request.getHeader(headerName));
}
response.setContentType("text/html;charset=utf-8");
PrintWriter out = response.getWriter();
Date date = new Date();
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String thisdate = sf.format(date);
out.println(thisdate);
out.close();
System.out.println("请求方式:"+request.getMethod());
System.out.println("请求的协议种类:"+request.getProtocol());
System.out.println("请求资源路径:"+request.getRequestURI());
System.out.println("请求Servlet路径:"+request.getServletPath());
}
}
最近下载更多
lwp011 LV27
2022年9月27日
yeyuantao LV6
2021年7月8日
安心猪 LV2
2020年7月22日
miracle_gl LV2
2019年9月12日
jxly007 LV8
2019年9月7日
liujiaweijv LV7
2019年7月12日
xfeistar LV1
2019年5月27日
hughhello LV2
2019年1月3日
tonnyapm LV2
2018年10月24日
zhanqiu LV1
2018年8月14日
最近浏览更多
微信网友_6446523832586240 LV1
2024年2月29日
fesfefe LV13
2023年11月1日
1358849392 LV21
2022年11月10日
abc562311934 LV4
2022年10月8日
lwp011 LV27
2022年9月27日
huan941007 LV3
2022年8月29日
是你爸爸啊100 LV5
2022年8月8日
740330437 LV1
2022年6月19日
chengqiang LV13
2022年6月2日
微信网友_5957378031800320 LV3
2022年5月18日

