Chinaunix首页 | 论坛 | 博客
  • 博客访问: 102480
  • 博文数量: 51
  • 博客积分: 2510
  • 博客等级: 少校
  • 技术积分: 580
  • 用 户 组: 普通用户
  • 注册时间: 2009-01-05 16:28
文章分类

全部博文(51)

文章存档

2009年(51)

我的朋友

分类: Java

2009-01-06 16:44:30

一、out对象://信息送到客户端,生命周期:当前页

javax.servlet.jsp.Jspwriter类的子类的对象

方法:

print() println() write() 
格式:

out.print("string");

newLine() //输出换行符 
格式:

out.newLine();

flush() //输出缓冲区内容 
格式:

out.flush();

close() //关闭输出流 
格式:

out.close();


二、response对象:

javax.servlet.http.HttpServletResponse类的子类的对象

方法:

sendRedirect() //重定向 
格式:

response.sendRedirect("URL");

setContentType() 
格式:

response.setContentType("MIME");

//MIME:text/html(网页),text/plain(文本),application/x-msexcel(Excel文件),application/msword(Word文件)

setHeader() 
格式:

response.setHeader("HEADER");

//设置缓冲区

三、request对象:

javax.servlet.HttpServletRequest类的子类的对象

读取表单信息: 
格式:

request.getParameter("param");

Enumeration params=request.getParameterNames(); //获取所有的参数名

获取环境变量信息: 
编码格式: 
默认字符编码:ISO-8859-1

格式:

request.setCharacterEncoding("GBK");

<% //转换字符编码
String str=request.getParameter("param");
byte b[]=str.getBytes("ISO-8859-1");
str=new String(b);
%>


四、application对象:

格式:

application.setAttribute(key,obj); //添加属性

application.getAttribute(key); //获取关键字key的对象

application.removeAttribute(key); 


五、session对象:

javax.servlet.http.HttpSession类的子类的对象

sessionID: 
格式:

session.getId();

自定义属性: 
格式:

session.setAttribute(key,obj);

session.getAttribute(key);

session.removeAttribute(key); 


六、cookie对象:

格式:

cookie cook=new cookie(name,value);
response.addCookie(cook);

cookie cookies[]=request.getCookies();

cookies[i].getName()

cookies[i].getValue()

阅读(307) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~