package smartupload;
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)
{
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 = 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;
}
}
}
public int save(String s) throws ServletException,IOExcepti
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
一、项目简介 本项目是一套基于Servlet+jsp网上订餐系统,主要针对计算机相关专业的正在做bishe的学生和需要项目实战练习的Java学习者。 包含:项目源码、数据库脚本等,该项目可以直接作为bishe使用。 项目都经过严格调试,确保可以运行! 二、技术选择 处于安全性,功能可扩展性。我们采用java ee。 数据库使用开源的Mysql; 服务器采用Tomcat; 三、系统的运行环境及工具 Web服务器:Tomcat7及其以上版本 数据库服务器:Mysql5及以上 eclipse或者idea navicat 四、系统功能描述 用户注册 用户登录 菜品分类 菜品浏览 菜品订购 菜品查询 订餐 我的订餐车 清空订餐车 订单修改 留言板 公告 修改密码 修改个人信息 管理员
资源推荐
资源详情
资源评论
收起资源包目录
基于Servlet+jsp网上订餐系统 (209个子文件)
SmartUpload.class 17KB
SmartFile.class 6KB
ShoppingServlet.class 4KB
LoanBookServlet.class 4KB
AddBookServlet.class 4KB
ListServlet.class 4KB
DelServlet.class 4KB
PwdNameUserServlet.class 4KB
StatisticServlet.class 3KB
OrderList2Servlet.class 3KB
ReckoningBean.class 3KB
LeaveWordServlet.class 3KB
ModifyUserServlet.class 3KB
KuXiaoServlet.class 3KB
UpdateBookServlet.class 3KB
OrderListServlet.class 3KB
RegServlet.class 3KB
BookinfServlet.class 3KB
OrderList1Servlet.class 3KB
SearchServlet.class 3KB
GetbackPwdServlet.class 3KB
ServletUpload.class 3KB
ShowUserServlet.class 3KB
StockAddServlet.class 3KB
UpdateTypeServlet.class 3KB
EmpAddServlet.class 3KB
BeforehandBookServlet.class 3KB
EmpSearchServlet.class 2KB
NutritionAddServlet.class 2KB
AdminLoginServlet.class 2KB
ReckoningServlet.class 2KB
UserLoginServlet.class 2KB
AddTypeServlet.class 2KB
EmpEstateServlet.class 2KB
AdminShowUserServlet.class 2KB
ContinueBookServlet.class 2KB
EmpReworkServlet.class 2KB
AdminLoginBean.class 2KB
UserLoginBean.class 2KB
SelectBean.class 2KB
RemoveServlet.class 2KB
HuanBookServlet.class 2KB
SmartRequest.class 2KB
Validate.class 2KB
SmartFiles.class 2KB
SessAdminServlet.class 2KB
SessLoginServlet.class 2KB
DBConn.class 1KB
InsertUpdateDelBean.class 1KB
SmartUploadException.class 370B
.classpath 836B
org.eclipse.wst.common.component 458B
org.eclipse.wst.jsdt.ui.superType.container 49B
lucfron.css 3KB
css.css 1KB
Thumbs.db 54KB
Thumbs.db 6KB
dqianggandoufusi.gif 15KB
dhuanggualapi.gif 14KB
djiangzhuer.gif 13KB
dlvrou.gif 13KB
djianggujia.gif 12KB
maininfo.gif 12KB
dmuxurou.gif 12KB
dzhuroiudunfentiao.gif 12KB
ddagusuancai.gif 10KB
emptybook.gif 3KB
cart04.gif 2KB
cart02.gif 2KB
xsph.gif 2KB
cart01.gif 2KB
xsph1.gif 2KB
hydl.gif 2KB
view0.gif 2KB
cpfl.gif 2KB
tu1.gif 971B
close.gif 954B
goumai2.gif 920B
goumai.gif 913B
goumai1.gif 864B
shopcart2.gif 856B
view2.gif 648B
dp_bg.gif 604B
dp_bg3.gif 603B
th_img2.gif 465B
th_img.gif 465B
tu2.gif 227B
trash.gif 179B
class1.gif 178B
class2.gif 174B
bg_bot.gif 168B
th_bg.gif 85B
class3.gif 79B
tu_bg.gif 56B
bj_x1.gif 51B
mysql-connector-java-5.0.8-bin.jar 528KB
SmartUpload.java 27KB
SmartFile.java 7KB
ShoppingServlet.java 4KB
ListServlet.java 4KB
共 209 条
- 1
- 2
- 3
资源评论
- 努力的小强同学2023-05-29资源质量不错,和资源描述一致,内容详细,对我很有用。
飞翔的佩奇
- 粉丝: 3500
- 资源: 728
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 前端开发-什么是前端开发-关于前端开发的一些相关介绍
- Sora AI-关于文生视频的使用场景说明
- suno AI文生视频的相关教程和介绍使用
- 什么是后端开发-关于后端开发的一些小介绍分享
- Jurassic Pack Vol. II Dinosaurs 侏罗纪包卷恐龙二号Unity游戏模型资源unitypackage
- Jurassic Pack Vol. III Dinosaurs 侏罗纪包卷恐龙三号Unity游戏模型资源unitypackag
- Ultimate Seating Controller 终极座椅控制器Unity游戏开发插件资源unitypackage
- 什么是人工智能-关于人工智能的相关介绍说明
- Figma Converter for Unity适用Unity的Figma转换器Unity游戏开发插件unitypackage
- Creepy Animatronic Anims 令人毛骨悚然的电子动画Unity游戏动画插件资源unitypackage
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功