package com.util;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
public class SmartUpload
{
protected byte m_binArray[];
protected HttpServletRequest m_request;
protected HttpServletResponse m_response;
protected ServletContext m_application;
private int m_totalBytes;
private int m_currentIndex;
private int m_startData;
private int m_endData;
private String m_boundary;
private long m_totalMaxFileSize;
private long m_maxFileSize;
private Vector m_deniedFilesList;
private Vector m_allowedFilesList;
private boolean m_denyPhysicalPath;
//private boolean m_forcePhysicalPath;
private String m_contentDisposition;
public static final int SAVE_AUTO = 0;
public static final int SAVE_VIRTUAL = 1;
public static final int SAVE_PHYSICAL = 2;
private SmartFiles m_files;
private SmartRequest m_formRequest;
public SmartUpload()
{
m_totalBytes = 0;
m_currentIndex = 0;
m_startData = 0;
m_endData = 0;
m_boundary = ""; //new String();
m_totalMaxFileSize = 0L;
m_maxFileSize = 0L;
m_deniedFilesList = new Vector();
m_allowedFilesList = new Vector();
m_denyPhysicalPath = false;
//m_forcePhysicalPath = false;
m_contentDisposition = ""; //new String();
m_files = new SmartFiles();
m_formRequest = new SmartRequest();
}
/**
* @deprecated Method init is deprecated
*/
public final void init(ServletConfig servletconfig) throws ServletException
{
m_application = servletconfig.getServletContext();
}
/**
* @deprecated Method service is deprecated
*/
public void service(HttpServletRequest httpservletrequest,HttpServletResponse httpservletresponse) throws ServletException,IOException
{
m_request = httpservletrequest;
m_response = httpservletresponse;
}
public final void initialize(ServletConfig servletconfig,HttpServletRequest httpservletrequest,HttpServletResponse httpservletresponse) throws ServletException
{
m_application = servletconfig.getServletContext();
m_request = httpservletrequest;
m_response = httpservletresponse;
}
public final void initialize(PageContext pagecontext) throws ServletException
{
m_application = pagecontext.getServletContext();
m_request = (HttpServletRequest)pagecontext.getRequest();
m_response = (HttpServletResponse)pagecontext.getResponse();
}
/**
* @deprecated Method initialize is deprecated
*/
public final void initialize(ServletContext servletcontext,HttpSession httpsession,HttpServletRequest httpservletrequest,HttpServletResponse httpservletresponse,JspWriter jspwriter) throws ServletException
{
m_application = servletcontext;
m_request = httpservletrequest;
m_response = httpservletresponse;
}
public void upload() throws ServletException,IOException,SmartUploadException
{
int i = 0;
//boolean flag = false;
boolean flag1 = false;
//boolean flag2 = false;
long l = 0L;
//String s = "";//new String();
//String s2 = "";//new String();
String s4 = ""; //new String();
String s5 = ""; //new String();
String s6 = ""; //new String();
String s7 = ""; //new String();
String s8 = ""; //new String();
String s9 = ""; //new String();
String s10 = ""; //new String();
m_totalBytes = m_request.getContentLength();
m_binArray = new byte[m_totalBytes];
int j;
for(;i < m_totalBytes;i += j)
{
try
{
m_request.getInputStream();
j = m_request.getInputStream().read(m_binArray,i,m_totalBytes - i);
}
catch(Exception exception)
{
throw new SmartUploadException("Unable to upload.");
}
}
for(;!flag1 && m_currentIndex < m_totalBytes;m_currentIndex++)
{
if(m_binArray[m_currentIndex] == 13)
{
flag1 = true;
}
else
{
m_boundary = m_boundary + (char)m_binArray[m_currentIndex];
}
}
if(m_currentIndex == 1)
{
return;
}
for(m_currentIndex++;m_currentIndex < m_totalBytes;m_currentIndex = m_currentIndex + 2)
{
long now=new java.util.Date().getTime();
String s1 = getDataHeader();
m_currentIndex = m_currentIndex + 2;
boolean flag3 = s1.indexOf("filename") > 0;
String s3 = getDataFieldValue(s1,"name");
if(flag3)
{
s6 = getDataFieldValue(s1,"filename");
s4 = now+getFileName(s6);
s5 = getFileExt(s4);
s7 = getContentType(s1);
s8 = getContentDisp(s1);
s9 = getTypeMIME(s7);
s10 = getSubTypeMIME(s7);
}
getDataSection();
if(flag3 && s4.length() > 0)
{
if(m_deniedFilesList.contains(s5))
{
throw new SecurityException("The extension of the file is denied to be uploaded (1015).");
}
if(!m_allowedFilesList.isEmpty() && !m_allowedFilesList.contains(s5))
{
throw new SecurityException("The extension of the file is not allowed to be uploaded (1010).");
}
if(m_maxFileSize > 0L && (long)((m_endData - m_startData) + 1) > m_maxFileSize)
{
throw new SecurityException("Size exceeded for this file : " + s4 + " (1105).");
}
l += (m_endData - m_startData) + 1;
if(m_totalMaxFileSize > 0L && l > m_totalMaxFileSize)
{
throw new SecurityException("Total File Size exceeded (1110).");
}
}
if(flag3)
{
SmartFile file = new SmartFile();
file.setParent(this);
file.setFieldName(s3);
file.setFileName(s4);
file.setFileExt(s5);
file.setFilePathName(s6);
file.setIsMissing(s6.length() == 0);
file.setContentType(s7);
file.setContentDisp(s8);
file.setTypeMIME(s9);
file.setSubTypeMIME(s10);
if(s7.indexOf("application/x-macbinary") > 0)
{
m_startData = m_startData + 128;
}
file.setSize((m_endData - m_startData) + 1);
file.setStartData(m_startData);
file.setEndData(m_endData);
m_files.addFile(file);
}
else
{
String s11 = new String(m_binArray,m_startData,(m_endData - m_startData) + 1);
m_formRequest.putParameter(s3,s11);
}
if((char)m_binArray[m_currentIndex + 1] == '-')
{
break;
}
}
}
p
没有合适的资源?快使用搜索试试~ 我知道了~
JAVA JSP+MYSQL教务管理系统 下载
共141个文件
gif:47个
jsp:31个
class:20个
2星 需积分: 33 159 下载量 47 浏览量
2017-05-11
12:06:28
上传
评论 2
收藏 12.07MB ZIP 举报
温馨提示
系统总体上分为三个部分:学生用户模块,教师用户模块和超级管理员用户模块。
资源推荐
资源详情
资源评论
收起资源包目录
JAVA JSP+MYSQL教务管理系统 下载 (141个子文件)
JSP教务管理系统录像.avi 55.52MB
SmartUpload.class 16KB
StudentsBean.class 16KB
CourseBean.class 9KB
AdminBean.class 7KB
AdminServlet.class 7KB
StudentsServlet.class 6KB
SmartFile.class 6KB
YdServlet.class 6KB
DBO.class 3KB
BaseServlet.class 3KB
BaseBean.class 2KB
SystemBean.class 2KB
Common.class 2KB
SmartRequest.class 2KB
SmartFiles.class 2KB
MD5.class 1KB
Filter.class 936B
CheckCode.class 887B
Constant.class 674B
SmartUploadException.class 364B
.classpath 552B
css.css 10KB
default.css 463B
Thumbs.db 74KB
Thumbs.db 10KB
girl.gif 7KB
boy.gif 6KB
index_hz01.gif 5KB
5.gif 4KB
index_hz04.gif 3KB
4.gif 3KB
8.gif 3KB
index_hz05.gif 2KB
11.gif 2KB
Key.gif 2KB
6.gif 2KB
10.gif 2KB
7.gif 2KB
zhuce.gif 2KB
1.gif 2KB
logo.gif 1KB
12.gif 1KB
back.gif 1KB
sub.gif 1KB
9.gif 1KB
3.gif 1KB
button.gif 1KB
13.gif 1KB
2.gif 1KB
ip.gif 1KB
index_hz03.gif 1010B
ie.gif 991B
14.gif 987B
last.gif 899B
first.gif 897B
jump.gif 883B
next.gif 861B
pre.gif 861B
head1.gif 610B
headbg4.gif 578B
headarrow.gif 531B
index_hz02.gif 461B
nobody.gif 353B
inputbg8.gif 348B
email.gif 239B
home.gif 173B
qq.gif 169B
bar1.gif 84B
headbg5.gif 83B
icon.gif 62B
inputend.gif 57B
banner.gif 43B
msbase.jar 280KB
mssqlserver.jar 65KB
msutil.jar 58KB
SmartUpload.java 27KB
YdServlet.java 9KB
AdminBean.java 8KB
DBO.java 3KB
MD5.java 792B
Filter.java 650B
SmartUploadException.java 147B
jd.jpg 101KB
2.jpg 44KB
4.jpg 36KB
1.jpg 28KB
3.jpg 26KB
ad2.jpg 21KB
ad.jpg 19KB
1.jpg 11KB
5.jpg 9KB
bg1.jpg 3KB
frams_191.jpg 2KB
frams_166.jpg 1KB
frams_143.jpg 871B
frams_145.jpg 570B
calendar.js 20KB
Common.js 7KB
index.js 2KB
共 141 条
- 1
- 2
资源评论
- ITSnack2018-03-13不怎么好不怎么好
lvkanlin3329
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功