Request中的方法调用
几种方法的调用:
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中的方法调用的更多相关文章
- 第三章Struts2 Action中动态方法调用、通配符的使用
01.Struts 2基本结构 使用Struts2框架实现用登录的功能,使用struts2标签和ognl表达式简化了试图的开发,并且利用struts2提供的特性对输入的数据进行验证,以及访问Servl ...
- Struts2 Action中动态方法调用、通配符的使用
一.Struts2执行过程图: 二.struts2配置文件的加载顺序 struts-default.xml---struts-plugin.xml---struts.xml 具体步骤: 三.Actio ...
- UIViewController中各方法调用顺序及功能详解
UIViewController中各方法调用顺序及功能详解 UIViewController中loadView, viewDidLoad, viewWillUnload, viewDidUnload, ...
- Spring @Cacheable注解 && 事务@Transactional 在同一个类中的方法调用不生效
@Cacheable 注解在对象内部调用不会生效 代码示例:ProductServiceImpl.java public List<ProductInfoVO> getProductLis ...
- JNI系列——C文件中的方法调用Java中方法
1.创建xxx.jni包并在该包下实现一些Java的方法,和要调用的本地方法 2.实现MainActivity中的按钮点击事件-即点击按钮调用本地的方法 3.在C文件中的方法中回调Java的方法 3. ...
- struts2.3.15.3中动态方法调用默认是关闭的
初学ssh,用的struts2.3.15.3,使用了如下表单: <form action="/spring3/index/login.action" method=" ...
- javascript函数调用中的方法调用模式
最近想起来之前看过的一种js语法,感觉很实用,但是又想不起来具体的写法.然后在网上浏览了一段时间,终于成功的再现了记忆中的那种语法,嗯~,还是那个熟悉的味道! 代码如下: <script> ...
- JAVA中native方法调用
在Java中native是关键字.它一般在本地声明,异地用C和C++来实现.它的声明有几点要注意:1)native与访问控制符前后的关系不受限制.2)必须在返回类型之前.3)它一般为非抽象类方法.4) ...
- 转:UIViewController中各方法调用顺序及功能详解
UIViewController中loadView, viewDidLoad, viewWillUnload, viewDidUnload, viewWillAppear, viewDidAppear ...
随机推荐
- UML类图基本画法
转自:http://www.cnblogs.com/import-this/p/5330501.html 1. 类 类包括属性方法 下图的生命就是属性 代谢就是方法 2.基本关系 a.泛化(Gener ...
- Python之路: socket篇
(默认)与特定的地址家族相关的协议,如果是 ,则系统就会根据地址格式和套接类别,自动选择一个合适的协议 sk import socketip_port = ()sk = socket.socket( ...
- SQL Server 事务及回滚事务的几种方法
第一种: declare @iErrorCount int set@iErrorCount=0 begintran Tran1 insertinto t1(Id, c1) values( ...
- php 语法中有 let 吗?
来源:http://stackoverflow.com/questions/9705281/with-and-let-in-php use(&$a) 用 use ($parameter) 这种 ...
- A/C模式 是什么意思啊汽车知识问题_PCauto快问
body{ font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI& ...
- 配置 nginx location 实时查看 php-fpm 的状态
在Nginx.conf 里配置 location ~ ^/status$ { include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_ ...
- iOS js oc相互调用(JavaScriptCore)
http://blog.csdn.net/lwjok2007/article/details/47058795
- 10、手把手教你Extjs5(十)自定义模块的设计
从这一节开始我们来设计并完成一个自定义模块.我们先来确定一个独立的模块的所能定义的一些模块信息.以下信息只是我自己在开发过程中想到或用到的,希望有新的想法的或者有建议的跟贴回复. 一个独立模块包含以下 ...
- lpc1768的PWM使用
//p2.0 pwm1.1 void ALS_Init(void) //初始化 { LPC_SC->PCONP |= (1<<1)|(1<<2)|(1<&l ...
- FZU 1056 扫雷游戏
水题.统计一下周围有几个雷. #include<cstdio> #include<cstring> #include<cmath> #include<algo ...