/*
* 项目名 :北京五岳管理系统
* 副系统名 :从环境中读取和设置信息
* class名 :AdmitActionContext.java
* version :1.0
* 日期 :2005/07/07
* 著作权 :Copyright beijingwuyue 2005, All rights reserved.
*/
package admit.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
/**
*
* <p>Title: AdmitActionContext.java</p>
* <p>Description: 从环境中读取和设置信息</p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: 五岳</p>
*
* @author gongjian
* @version 1.0
*/
public class AdmitActionContext {
/**
* http servlet request
*/
private HttpServletRequest request = null;
/**
* http session
*/
private HttpSession session = null;
/**
* 构造方法,得到Request对象, 并新建session
*
* @param servlet HttpServletRequest
*/
public AdmitActionContext(HttpServletRequest request) {
this.request = request;
this.session = request.getSession();
}
/**
* 根据key从request中得到对应的值
*
* @param name
* @return String
*/
public String getParameter(String name) {
String value = this.request.getParameter(name);
if (value == null) {
value = "";
} else {
try {
value = new String(value.getBytes("ISO8859-1"),"gb2312");
} catch (Exception e) {
value = "";
}
}
return value;
}
/**
*
* @param name
* @return
*/
public String[] getParameters(String name){
String[] values = this.request.getParameterValues(name);
return values;
}
/**
* 将值和对应的key放入request中
* @param name key
* @param value value
*/
public void setRequestData(String name, Object value) {
this.request.setAttribute(name, value);
}
/**
* 将值和对应的key放入session中
*
* @param name mapping name
* @param value object
*/
public void setSessionData(String name, Object value) {
this.session.setAttribute(name, value);
}
/**
* 根据key从session中得到对应的值
* @param name
* @return
*/
public Object getSessionData(String name) {
return this.session.getAttribute(name);
}
/**
* 根据key从session中删除对应的值
*
* remove Session Attribute
*/
public void removeSessionAttribute(String name) {
this.session.removeAttribute(name);
}
}