java编写的b/s结构的文件上传程序
源代码在线查看: jsp1_0002ejsp_jsp.java
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.util.Vector;
import org.apache.jasper.runtime.*;
import java.beans.*;
import org.apache.jasper.JasperException;
import java.io.ByteArrayOutputStream;
import org.apache.jasper.compiler.ibmtsx.*;
import org.apache.jasper.compiler.ibmdb.*;
import java.sql.SQLException;
public class jsp1_0002ejsp_jsp extends HttpJspBase {
// begin [file="D:\\work\\fileupload\\defaultroot\\jsp1.jsp";from=(1,0);to=(1,75)]
// end
static {
}
public jsp1_0002ejsp_jsp( ) {
}
private static boolean _jspx_inited = false;
private static boolean checkedAttributeIgnoreException = false;
private static boolean throwException = true;
public final void _jspx_init() throws JasperException {
}
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
JspFactory _jspxFactory = null;
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
String _value = null;
setBooleanIgnoreException();
try {
if (_jspx_inited == false) {
_jspx_init();
_jspx_inited = true;
}
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html;charset=gb2312");
pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
// HTML // begin [file="D:\\work\\fileupload\\defaultroot\\jsp1.jsp";from=(0,49);to=(1,0)]
out.print("\r\n"); // end
// begin [file="D:\\work\\fileupload\\defaultroot\\jsp1.jsp";from=(1,0);to=(1,75)]
fileupload.FileUploadBean TheBean = null;
boolean _jspx_specialTheBean = false;
synchronized (pageContext) {
TheBean= (fileupload.FileUploadBean)
pageContext.getAttribute("TheBean",PageContext.PAGE_SCOPE);
if ( TheBean == null ) {
_jspx_specialTheBean = true;
try {
TheBean = (fileupload.FileUploadBean) Beans.instantiate(getClassLoader(), "fileupload.FileUploadBean");
} catch (Exception exc) {
throw new ServletException (" Cannot create bean of class "+"fileupload.FileUploadBean");
}
pageContext.setAttribute("TheBean", TheBean, PageContext.PAGE_SCOPE);
}
}
if(_jspx_specialTheBean == true) {
// end
// begin [file="D:\\work\\fileupload\\defaultroot\\jsp1.jsp";from=(1,0);to=(1,75)]
}
// end
// HTML // begin [file="D:\\work\\fileupload\\defaultroot\\jsp1.jsp";from=(1,75);to=(3,0)]
out.print("\r\n\r\n"); // end
// begin [file="D:\\work\\fileupload\\defaultroot\\jsp1.jsp";from=(3,2);to=(10,0)]
TheBean.doUpload(request);
out.println("Filename:" + TheBean.getFilename());
out.println("内容类型:" + TheBean.getContentType());
out.println("作者:" + TheBean.getFieldValue("author"));
out.println("公司:" + TheBean.getFieldValue("aompany"));
out.println("说明:" + TheBean.getFieldValue("comment"));
// end
// HTML // begin [file="D:\\work\\fileupload\\defaultroot\\jsp1.jsp";from=(10,2);to=(11,0)]
out.print("\r\n"); // end
} catch (Exception ex) {
if (out.getBufferSize() != 0)
out.clearBuffer();
pageContext.handlePageException(ex);
} catch ( Throwable t) {
if (out.getBufferSize() != 0)
out.clearBuffer();
pageContext.handlePageException(new Exception(t.getMessage()));
} finally {
out.flush();
_jspxFactory.releasePageContext(pageContext);
}
}
private void setBooleanIgnoreException() {
if (checkedAttributeIgnoreException) return;
checkedAttributeIgnoreException = true;
String initParamIgnoreException =(String)(getServletConfig().getInitParameter("jsp.repeatTag.ignoreException"));
if ((initParamIgnoreException != null) && (initParamIgnoreException.toLowerCase().equals("true"))){
throwException = false;
}
}
}