Use jspsmartupload for upload and download

Source: Internet
Author: User

This is for upload

Import java. SQL .*;
Import java. io .*;
Import java. util .*;
Import javax. servlet .*;
Import javax. servlet. http .*;
Import com. jsp (preferred for SUN Enterprise Applications) smart. upload .*;

Public class UpLoad extends HttpServlet {

Private ServletConfig config;
/**
* Init the servlet
*/
Final public void init (ServletConfig config) throws ServletException {
This. config = config;
}

Final public ServletConfig getServletConfig (){
Return config;
}

Public void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
DoPost (request, response );
}

Public void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System. out. println ("============= UpLoad ddd in ddd ================ ");
String id = null;
SmartUpload mySmartUpload = new SmartUpload ();
PrintWriter out = response. getWriter ();
Java. io. File file = null;
Try {
Class. forName ("Oracle (large website database platform). jdbc. driver. Oracle (large website database platform) Driver ");
} Catch (java. lang. ClassNotFoundException e ){
System. err. print ("ClassNotFoundException:" + e. getMessage ());
}

Try {
// Class. forName ("Oracle (large website database platform). jdbc. driver. Oracle (large website database platform) Driver ");
Connection conn = DriverManager. getConnection ("jdbc: Oracle (large website database platform): thin: @ 10.216.0.2: 1521: ORCL", "test", "test ");

Conn. setAutoCommit (false); // set manual submission to improve performance.
Statement stmt = conn. createStatement ();
// Initialization
MySmartUpload. initialize (config, request, response );

MySmartUpload. setMaxFileSize (500*1024 );

// Upload
MySmartUpload. upload ();

// Obtain the data in the text box
Id = mySmartUpload. getRequest (). getParameter ("id ");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.