Servlet学习总结
来源:互联网 发布:windows返回快捷键 编辑:程序博客网 时间:2024/05/16 23:52
package com.test;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.io.IOException;import java.io.PrintWriter;/** Servlet输出客户端发送的请求信息 * Created with IntelliJ IDEA. * User: Administrator * Date: 15-8-18 * Time: 下午11:25 * To change this template use File | Settings | File Templates. */public class RequestInfo extends HttpServlet{ public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException { //重写doGet方法 response.setContentType("text/html;charset=GB2312");//设置响应头部 PrintWriter out = response.getWriter(); /*HttpServletResponse对象生成响应 *响应对象把含有getWriter()方法返回给一个叫PrintWriter对象。 * 使用PrintWriter的print()和Print()方法以编写Servlet响应返回给客户端 */ out.println("<HTML>"); out.println("<body>"); out.println("<head>"); out.println("<title>RequestInformationExample</title>"); out.println("</head>"); out.println("<body>"); out.println("<h3>RequestInformationExample</h3>"); out.println("Method:"+request.getMethod()); out.println("RequestURI:"+request.getRequestURI()); out.println("Protocol:"+request.getProtocol()); out.println("PathInfo:"+request.getPathInfo()); out.println("RemoteAddress:"+request.getRemoteAddr()); out.println("<body>"); out.println("</HTML>"); } public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException{ doGet(request, response);//doPost()把请求送给doGet方法 }}
1 0
- servlet 学习 总结。
- servlet学习总结
- Servlet学习总结
- 学习Servlet总结
- Servlet 学习总结-1
- Servlet 学习总结-2
- Servlet 学习总结
- Servlet学习总结
- Servlet/JSP学习总结
- Servlet学习总结
- JSP/servlet学习总结
- Servlet学习总结一
- Servlet学习总结
- Servlet、JSP学习总结
- Servlet学习与总结
- servlet学习总结
- servlet学习总结
- servlet学习总结一
- Android通过startService播放背景音乐简单示例
- Fair Division
- POJ 青蛙的约会 1061【经典数论-扩展欧几里得】
- hdoj 2222 Keywords Search 【AC自动机 入门题】 【求目标串中出现了几个模式串】
- 数论基础的补充讲解
- Servlet学习总结
- pull方式解析xml文件以及用Serializer序列化器生成xml文件
- 计算机进制理解
- samba服务器配置文件示例
- FiniteTimeAction,Follow,Speed源码分析
- VC写加密壳
- B2B移动商务社交平台贸人E家APP在深首发
- poj2388Who's in the Middle【堆排序】
- 第三方微博登陆,通过OAuth 2.0 进行授权