几种方法的调用:

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. Enterprise Architect与startUML表示UML常用图

    转自:http://www.cnblogs.com/alexlee73/archive/2011/11/05/2237294.html 附下载地址:http://download.csdn.net/d ...

  2. ScreenCaptureHtmlUnitDriver.java

    https://github.com/apache/incubator-zeppelin/blob/master/zeppelin-server/src/test/java/com/webautoma ...

  3. 使用bootstrap响应式布局——手机屏幕中横向滚动显示标签页选项

    导航栏到小屏幕的时候,我们的处理办法是隐藏为一个按钮.可是选项卡的标签页部分,我们的处理办法是加一个水平滚动条.但是加水平滚动条需要解决一个问题,就是宽度的问题,如果不设置宽度,他就会根据屏幕大小自适 ...

  4. JQuery的插件开发——重点

    1.给JQuery全局对象扩展一个函数方法 $.log=function(){ /* 给全局对象$扩展一个函数*/ } $.log;//调用方法 2.给JQuery普通对象扩展一个函数方法 3.使用第 ...

  5. Unity NGUI UIPanel下对粒子的剪裁

    使用 unity 做游戏开发时,有时需要在scroll view下使用粒子,但粒子是不会被 UIPanel 所裁剪的,本人提供了脚本 ParticleSystemClipper,用来处理这种情况.思路 ...

  6. 远离DoS攻击 Windows Server 2016发布DNS政策

             Windows Server 2016的网络功能虽然没有获得像Docker容器和Nano Server同等重要的关注,但是管理员们应该了解的是,新的域名系统(Domain Name ...

  7. 关于eclipse创建Maven项目创建的问题

    1.问题: 为什么Maven Update Project JDK变回1.5 解释:官方文档 The Compiler Plugin is used to compile the sources of ...

  8. cron 编辑器修改

    更改 cron 默认编辑工具 Debian 的 crontab 默认的编辑器是 nano,用起来很不习惯,怎么才能转回 VI 呢? 用如下命令即可: #update-alternatives --co ...

  9. <iOS>UIImage变为NSData并进行压缩

    http://www.cnblogs.com/robinkey/archive/2013/01/21/2869930.html //sdk中提供了方法可以直接调用 UIImage *img = [UI ...

  10. Memcached源码分析之assoc.c

    #include "memcached.h" #include <sys/stat.h> #include <sys/socket.h> #include ...