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 ...
随机推荐
- 如何把mysql的ID归0?
如何把mysql的ID归0 可以归0的,truncate table + 表名 就行了
- 计算机学院大学生程序设计竞赛(2015’12) 1005 Bitwise Equations
#include<cmath> #include<cstdio> #include<cstring> #include<algorithm> using ...
- 微信小程序实例教程(三)
第七章:微信小程序编辑名片页面开发 编辑名片有两条路径,分为新增名片流程与修改名片流程. 用户手填新增名片流程: 首先跳转到我们的新增名片页面 1 需要传递用户的当前 userId,wx.na ...
- cdr格式文件抠图
使用CoreDRAW打开cdr文件,另存为ai格式 使用illustrator打开新文件,使用套索工具选择需要的图形,复制到photoshop中进行编辑
- Android Camera HAL浅析
1.Camera成像原理介绍 Camera工作流程图 Camera的成像原理可以简单概括如下: 景物(SCENE)通过镜头(LENS)生成的光学图像投射到图像传感器(Sensor)表面上,然后转为电信 ...
- (简单) POJ 3074 Sudoku, DLX+精确覆盖。
Description In the game of Sudoku, you are given a large 9 × 9 grid divided into smaller 3 × 3 subgr ...
- php中使用mysql_fetch_array输出数组至页面中展示
用的是CI框架,很好的MVC结构 在Model层 public function showProteinCategory(){ $sql = "SELECT DISTINCT protein ...
- 18、手把手教你Extjs5(十八)模块记录的拖放删除、拖放复制新增
网页当中的拖放(drag-drop)是比较有趣的操作,extjs5中很好的封装了拖放的动作,也有各种类来支持,但是要学好“拖放”这个东西真是很难,特别是象我这样英语不好的人,看不太懂官网上的说明,做一 ...
- uoj#38. 【清华集训2014】奇数国【欧拉函数】
number⋅x+product⋅y=1 有整数x,y解的条件是gcd(number, product) == 1. product用线段树维护一下,然后现学了个欧拉函数. 可以这样假如x = p ...
- 《算法导论》习题2.3-6 改进的InsertSort
InsertSort中有关键的一步是把当前元素A[i]插入到已经排好序的A[1,i-1]的合适的位置上,在原始的InsertSort算法中, 采用的是从后往前一步一步查找的方法,习题2.3-6要求利用 ...