JSP upload image and generate thumbnails
This example uses the JSPSMART component to upload, here you can download the component www.jspsmart.com After downloading the decompression, copy the JAR package to the / web-inf / lib directory to restart the server, JSPSmart can be used normally.
1, UploadImage.jsp
<% @ Page ContentType = "Text / HTML; Charset = GB2312" Language = "Java" Import = "java.io. *, java.awt.codec, java.awt.image. *, com.sun.image.codec .jpeg. *, java.sql. *, com.jspsmart.upload. *, java.util. * "%> <% smartupload mysmartupload = new smartupload (); long file_size_max = 4000000; string filename2 =" ", ext = "", testvar = ""; string url = "UPLOADFILE / IMAGES /"; // Should be guaranteed to have this directory in the root directory // initialization mysmartupload.initialize (PageContext); // Only allowed to upload this file TRY {Mysmartupload.setAllowedFileSlist ("JPG, GIF"); // Upload file mysmartupload.upload ();} catch (Exception E) {%>