JSP的九个隐含对象
一、page 对象
page对象代表JSP本身,更准确地说它代表JSP被转译后的Servlet,它可以调用Servlet类所定义的方法。
二、config 对象
config 对象里存放着一些Servlet 初始的数据结构。
config 对象实现于javax.servlet.ServletConfig 接口,它共有下列四种方法:
public String getInitParameter(name)
public java.util.Enumeration getInitParameterNames( )
public ServletContext getServletContext( )
public Sring getServletName( )
三、request 对象
request 对象包含所有请求的信息,如:请求的来源、标头、cookies和请求相关的参数值等等。
request 对象实现javax.servlet.http.HttpServletRequest接口的,所提供的方法可以将它分为四大类:
1.储存和取得属性方法;
void setAttribute(String name, Object value) 设定name属性的值为value
Enumeration getAttributeNamesInScope(int scope) 取得所有scope 范围的属性
Object getAttribute(String name) 取得name 属性的值
void removeAttribute(String name) 移除name 属性的值
2.取得请求参数的方法
String getParameter(String name) &
相关文档:
定义一个session变量
session.setAttribute("user_name","joan");
读取一个session的值:
String your_name=session.getAttribute("user_name");
判断一个session是否存在应用:
if((String)session.getAttribute("user_id")==null)
{
out.print("yes");
}
else
{
out.print("no");
}
写入一个cook ......
一、page 对象
page对象代表JSP本身,更准确地说它代表JSP被转译后的Servlet,它可以调用Servlet类所定义的方法。
二、config 对象
config 对象里存放着一些Servlet 初始的数据结构。
config 对象实现于javax.servlet.ServletConfig 接口,它共有下列四种方法:
......
1、 最基本的乱码问题。
这个乱码问题是最简单的乱码问题。一般新会出现。就是页面编码不一致导致的乱码。
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=iso8859-1"%>
<html>
<head>
<title>中文问题</title>
<meta http-equi ......
许多Web应用、企业应用涉及到长时间的操作,例如复杂的数据库查询或繁重的XML处理等,虽然这些任务主要由数据库系统或中间件完成,但任务执行的结果仍旧要借助JSP才能发送给用户。本文介绍了一种通过改进前端表现层来改善用户感觉、减轻服务器负载的办法。
当JSP调用一个必须长时间运行的操作,且该操作的结果不能(在服务 ......
<?xml version="1.0" encoding="gb2312" ?>
<?xml-stylesheet type="tet/css" href="mystyle.css" ?>
<%@ page errorPage="error.jap" %>
<%@ page contentType="text/xml" %>
<realmarid>
皇马花名册
<athlete>
<name>齐达内</name>
<country> ......