package
net.java2000.tools;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletInputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
/**
* <p>
* Title: Java 程序
* </p>
* <p>
* Description: 通用的请求处理程序,能够处理上传方式
* </p>
*
* <pre>
* 一般使用方法如下
* <%
* 指定编码方式
* request.setCharacterEncoding("GBK");
* // 为 文件上传 做准备,该类读取接口与 request 相同
* net.java2000.tools.Upload upload = new net.java2000.tools.Upload(request);
* // 解析
* upload.parse();
* %>
* ...
* <%
* //使用标准方法读取参数
* String name = upload.getParameter("Name");
* String[] names = upload.getParameterValues("nameMultiSelected");
* <br/>
* // 读取上传信息,比如上传照片
* <form method="POST" name="form1" enctype="multipart/form-data" action="" onsubmit="return check();">
* <input type="file" name="photo" size="8" value="更新照片">
* </form>
* // 读取表单值,也就是照片的实际信息,请注意,该方法名包含Org,和前面的不同
* // 由于上传信息经常是二进制内容,所以不能采用编码后的字符串,应采用和流完全对应的字符串
* String photo = upload.getParameterOrg("photo"); // 此方法读取原始信息,没有进行任何编码,即ISO-8859-1 格式
* // 如果转化为字节数组为
* byte[] bytes = photo.getBytes("iso-8859-1");
* // 读取照片的类型
* String contentType = upload.getContentType("photo");
* // 读取照片文件名,不包含路径
* String filename = upload.getFilename("photo");
* %>
* 请在尽可能前的地方使用,特别是<b>不要</b>再使用了
* request.getParameter("XXX");
* 后面使用,因为这时候的输入流已经被系统使用了。
* </pre>
*
* <p>
* Copyright: Copyright (c) 2002
* </p>
* <p>
* Company:
* </p>
*
* @author 赵学庆
* @version 1.0
*/
public class Upload implements HttpServletRequest {
private HttpServletRequest request = null ;
public Upload(HttpServletRequest request) {
this .request = request;
}
public Object getAttribute(String name) {
return request.getAttribute(name);
}
public java.util.Enumeration getAttributeNames() {
return request.getAttributeNames();
}
public java.lang.String getCharacterEncoding() {
return request.getCharacterEncoding();
}
public void setCharacterEncoding(String env) throws java.io.UnsupportedEncodingException {
request.setCharacterEncoding(env);
}
public int getContentLength() {
return request.getContentLength();
}
public int getLocalPort() {
return request.getLocalPort();
}
public String getLocalAddr() {
return request.getLocalAddr();
}
public String getLocalName() {
return request.getLocalName();
}
public int getRemotePort() {
return request.getRemotePort();
}
public java.lang.String getContentType() {
return request.getContentType();
}
public ServletInputStream getInputStream() throws java.io.IOException {
return request.getInputStream();
}
public java.util.Map getParameterMap() {
return request.getParameterMap();
}
public java.lang.String getProtocol() {
return request.getProtocol();
}
public java.lang.String getScheme() {
return request.getScheme();
}
public java.lang.String getServerName() {
return request.getServerName();
}
public int getServerPort() {
return request.getServerPort();
}
public java.io.BufferedReader getReader() throws java.io.IOException {
return request.getReader();
}
public java.lang.String getRemoteAddr() {
return request.getRemoteAddr();
}
public java.lang.String getRemoteHost() {
return request.getRemoteHost();
}
public void setAttribute(java.lang.String name, Object o) {
request.setAttribute(name, o);
}
public void removeAttribute(java.lang.String name) {
request.removeAttribute(name);
}
public java.util.Locale getLocale() {
return request.getLocale();
}
public java.util.Enumeration getLocales() {
return request.getLocales();
}
public boolean isSecure() {
return request.isSecure();
}
public RequestDispatcher getRequestDispatcher(String path) {
return request.getRequestDispatcher(path);
}
public java.lang.String getRealPath(String path) {
return request.getRealPath(path);
}
public java.lang.String getAuthType() </spa>
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletInputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
/**
* <p>
* Title: Java 程序
* </p>
* <p>
* Description: 通用的请求处理程序,能够处理上传方式
* </p>
*
* <pre>
* 一般使用方法如下
* <%
* 指定编码方式
* request.setCharacterEncoding("GBK");
* // 为 文件上传 做准备,该类读取接口与 request 相同
* net.java2000.tools.Upload upload = new net.java2000.tools.Upload(request);
* // 解析
* upload.parse();
* %>
* ...
* <%
* //使用标准方法读取参数
* String name = upload.getParameter("Name");
* String[] names = upload.getParameterValues("nameMultiSelected");
* <br/>
* // 读取上传信息,比如上传照片
* <form method="POST" name="form1" enctype="multipart/form-data" action="" onsubmit="return check();">
* <input type="file" name="photo" size="8" value="更新照片">
* </form>
* // 读取表单值,也就是照片的实际信息,请注意,该方法名包含Org,和前面的不同
* // 由于上传信息经常是二进制内容,所以不能采用编码后的字符串,应采用和流完全对应的字符串
* String photo = upload.getParameterOrg("photo"); // 此方法读取原始信息,没有进行任何编码,即ISO-8859-1 格式
* // 如果转化为字节数组为
* byte[] bytes = photo.getBytes("iso-8859-1");
* // 读取照片的类型
* String contentType = upload.getContentType("photo");
* // 读取照片文件名,不包含路径
* String filename = upload.getFilename("photo");
* %>
* 请在尽可能前的地方使用,特别是<b>不要</b>再使用了
* request.getParameter("XXX");
* 后面使用,因为这时候的输入流已经被系统使用了。
* </pre>
*
* <p>
* Copyright: Copyright (c) 2002
* </p>
* <p>
* Company:
* </p>
*
* @author 赵学庆
* @version 1.0
*/
public class Upload implements HttpServletRequest {
private HttpServletRequest request = null ;
public Upload(HttpServletRequest request) {
this .request = request;
}
public Object getAttribute(String name) {
return request.getAttribute(name);
}
public java.util.Enumeration getAttributeNames() {
return request.getAttributeNames();
}
public java.lang.String getCharacterEncoding() {
return request.getCharacterEncoding();
}
public void setCharacterEncoding(String env) throws java.io.UnsupportedEncodingException {
request.setCharacterEncoding(env);
}
public int getContentLength() {
return request.getContentLength();
}
public int getLocalPort() {
return request.getLocalPort();
}
public String getLocalAddr() {
return request.getLocalAddr();
}
public String getLocalName() {
return request.getLocalName();
}
public int getRemotePort() {
return request.getRemotePort();
}
public java.lang.String getContentType() {
return request.getContentType();
}
public ServletInputStream getInputStream() throws java.io.IOException {
return request.getInputStream();
}
public java.util.Map getParameterMap() {
return request.getParameterMap();
}
public java.lang.String getProtocol() {
return request.getProtocol();
}
public java.lang.String getScheme() {
return request.getScheme();
}
public java.lang.String getServerName() {
return request.getServerName();
}
public int getServerPort() {
return request.getServerPort();
}
public java.io.BufferedReader getReader() throws java.io.IOException {
return request.getReader();
}
public java.lang.String getRemoteAddr() {
return request.getRemoteAddr();
}
public java.lang.String getRemoteHost() {
return request.getRemoteHost();
}
public void setAttribute(java.lang.String name, Object o) {
request.setAttribute(name, o);
}
public void removeAttribute(java.lang.String name) {
request.removeAttribute(name);
}
public java.util.Locale getLocale() {
return request.getLocale();
}
public java.util.Enumeration getLocales() {
return request.getLocales();
}
public boolean isSecure() {
return request.isSecure();
}
public RequestDispatcher getRequestDispatcher(String path) {
return request.getRequestDispatcher(path);
}
public java.lang.String getRealPath(String path) {
return request.getRealPath(path);
}
public java.lang.String getAuthType() </spa>