码迷,mamicode.com
首页 > Web开发 > 详细

JSP&&SERVLET学习笔记(四):关于HttpServletRequest

时间:2014-12-23 13:57:33      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:

package cc.openhome;


import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@WebServlet("/header.view")
public class HeaderServlet extends HttpServlet {


@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>HeaderServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>HeaderServlet at " + request.getContextPath()+ " </h1>");
Enumeration<String> names = request.getHeaderNames();
while(names.hasMoreElements()){
String name = names.nextElement();
out.println(name + ": " + request.getHeader(name) + "<br>");

}
out.println("</body>");
out.println("</html>");
out.close();
}



}

JSP&&SERVLET学习笔记(四):关于HttpServletRequest

标签:

原文地址:http://blog.csdn.net/u012965373/article/details/42101827

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!