几种方法的调用:

package com.stono.servlet;

import java.io.IOException;
import java.util.Enumeration;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; public class TestServlet2 extends HttpServlet {
private static final long serialVersionUID = 1L; @Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
IOException {
System.out.println("do get method called!");
} @Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
IOException {
String method = req.getMethod();
System.out.println("method is " + method);
Enumeration<String> headerNames = req.getHeaderNames();
int i = 0;
while (headerNames.hasMoreElements()) {
String nextElement = headerNames.nextElement();
String header = req.getHeader(nextElement);
System.out.println(++i + ":" + nextElement + ":" + header);
}
System.out.println("===============COOKIE================");
Cookie[] cookies = req.getCookies();
for (Cookie cookie : cookies) {
System.out.println(cookie);
cookie.getName();
cookie.getValue();
cookie.getVersion();
}
System.out.println("================Remote===================");
String remoteAddr = req.getRemoteAddr();
String remoteHost = req.getRemoteHost();
int remotePort = req.getRemotePort();
String remoteUser = req.getRemoteUser();
System.out.println(remoteAddr);
System.out.println(remoteHost);
System.out.println(remotePort);
System.out.println(remoteUser);
System.out.println("================Server===================");
String serverName = req.getServerName();
int serverPort = req.getServerPort();
String servletPath = req.getServletPath();
System.out.println(serverName);
System.out.println(serverPort);
System.out.println(servletPath);
System.out.println("================Local===================");
String localAddr = req.getLocalAddr();
String localName = req.getLocalName();
int localPort = req.getLocalPort();
System.out.println(localAddr);
System.out.println(localName);
System.out.println(localPort); System.out.println("do post method called");
String[] strings = req.getParameterValues("txt1");
System.out.println(strings.length);
for (String string : strings) {
System.out.println(string);
}
}
}

Request中的方法调用的更多相关文章

  1. 第三章Struts2 Action中动态方法调用、通配符的使用

    01.Struts 2基本结构 使用Struts2框架实现用登录的功能,使用struts2标签和ognl表达式简化了试图的开发,并且利用struts2提供的特性对输入的数据进行验证,以及访问Servl ...

  2. Struts2 Action中动态方法调用、通配符的使用

    一.Struts2执行过程图: 二.struts2配置文件的加载顺序 struts-default.xml---struts-plugin.xml---struts.xml 具体步骤: 三.Actio ...

  3. UIViewController中各方法调用顺序及功能详解

    UIViewController中各方法调用顺序及功能详解 UIViewController中loadView, viewDidLoad, viewWillUnload, viewDidUnload, ...

  4. Spring @Cacheable注解 && 事务@Transactional 在同一个类中的方法调用不生效

    @Cacheable 注解在对象内部调用不会生效 代码示例:ProductServiceImpl.java public List<ProductInfoVO> getProductLis ...

  5. JNI系列——C文件中的方法调用Java中方法

    1.创建xxx.jni包并在该包下实现一些Java的方法,和要调用的本地方法 2.实现MainActivity中的按钮点击事件-即点击按钮调用本地的方法 3.在C文件中的方法中回调Java的方法 3. ...

  6. struts2.3.15.3中动态方法调用默认是关闭的

    初学ssh,用的struts2.3.15.3,使用了如下表单: <form action="/spring3/index/login.action" method=" ...

  7. javascript函数调用中的方法调用模式

    最近想起来之前看过的一种js语法,感觉很实用,但是又想不起来具体的写法.然后在网上浏览了一段时间,终于成功的再现了记忆中的那种语法,嗯~,还是那个熟悉的味道! 代码如下: <script> ...

  8. JAVA中native方法调用

    在Java中native是关键字.它一般在本地声明,异地用C和C++来实现.它的声明有几点要注意:1)native与访问控制符前后的关系不受限制.2)必须在返回类型之前.3)它一般为非抽象类方法.4) ...

  9. 转:UIViewController中各方法调用顺序及功能详解

    UIViewController中loadView, viewDidLoad, viewWillUnload, viewDidUnload, viewWillAppear, viewDidAppear ...

随机推荐

  1. 【HighCharts系列教程】八、Html标签属性——Labels

    一.labels属性说明 Labels属性允许在HighCharts图表的任意位置添加任意的html代码.可以实现许多自定义内容. 二.labels属性详解 参数 子参数 说明 默认值 items — ...

  2. gitlab应用

    1.git config --global user.email "my@bimt.com" //注册本地环境 2.ssh-keygen -t rsa -C "my@bi ...

  3. 二叉树查找(C#)

    参考文章: http://www.cnblogs.com/huangxincheng/archive/2012/07/21/2602375.html http://www.cnblogs.com/xi ...

  4. YouKu iOS笔试题一

    序言 最近收到某某同学将去youku的iOS笔试题的邮件,希望笔者能整理一下,并提供参考答案.笔者决定整理出来,并分享给大家.当然,与此同时,也想看看youku的笔试题到底有多难,也考考自己有多少料吧 ...

  5. Delphi XE7 Update1 下载破解、带源码和帮助安装序列号

    源:http://blog.csdn.net/tht2009/article/details/39157877 Delphi安装与破解 1.XE7 XE7Update1:http://altd.emb ...

  6. ios开发环境配置及cordova安装与常用命令

    一.ios开发环境配置 1.首先要有台Mac Book,如果有Mac Book,跳过步骤2.3.4,如果没有,执行步骤2.3.4: 2.下载并安装VMware Workstation,最好是下最新版本 ...

  7. 系统管理员必须掌握的20个Linux监控工具

    需要监控Linux服务器系统性能吗?尝试下面这些系统内置或附件的工具吧.大多数Linux发行版本都装备了大量的监控工具.这些工具提供了能用 作取得相关信息和系统活动的量度指标.你能使用这些工具发现造成 ...

  8. 【转】每一个程序员需要了解的10个Linux命令

    作为一个程序员,在软件开发职业生涯中或多或少会用到Linux系统,并且可能会使用Linux命令来检索需要的信息.本文将为各位开发者分享10个有用的Linux命令,希望对你会有所帮助. 以下就是今天我们 ...

  9. Thinking in scala (2)---- 最大公约数

    gcd.scala object gcd{ def main(args:Array[String]){ println( gcd1(args(0).toInt,args(1).toInt)) prin ...

  10. cocos2d中box2d讲解一

    在游戏中我们经常要加入物理碰撞等和物理有关的内容,在游戏中加入物理引擎可以使我们的游戏更加真实,为玩家展示一个更真实的世界,cocos2d-x支持两个物理引擎Box2d和Chipmunk,本文介绍bo ...