servlet实现上传下载完整代码.docx
文本预览下载声明
----------------------------------------jsp代码-----------------------------------------------------------------------------
form action=%=basePath %Upload method=post
input type=file name=file1
br
input type=file name=file2
br
input type=file name=file3
input type=submit value=upload /
br
br
a href=%=basePath %Down?downFile=%=URLEncoder.encode(JDK_API_1_6_zh_CN.CHM,utf-8 )%down/a
/form
----------------------------------上传upload.java------------------------------------------------------------------------
package com;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Upload extends HttpServlet {
/**
* Destruction of the servlet. br
*/
public void destroy() {
super.destroy(); // Just puts destroy string in log
// Put your code here
}
/**
* The doGet method of the servlet. br
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}
/**
* The doPost method of the servlet. br
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServle
显示全部