My JSP 'imageLoadTest.jsp' starting page
Servlet: mageLoadServlet. jsp
ImageLoadServlet = "jpg, gif, jpeg, png"; SmartUpload mySmartUpload = SmartUpload (); fileSizeMax = 1024*1024*10; String ext = ""; string url = "image/"; mySmartUpload. initialize (. getServletConfig (), request, response); mySmartUpload. setAllowedFilesList (allowedFilesList);} "only allow upload" + allowedFilesList + "Type Image" = mySmartUpload. getFiles (). getFile (0); (myFile. isMissing () {System. out. println ("select the file to upload" = myFile. getFileExt (); fileSize = myFile. getSize (); String saveurl = ""; (fileSize <= String. valueOf (Calendar. getInstance (). getTimeInMillis (); saveurl = request. getRealPath ("/"); saveurl + = url + filename + ". "+}" file saving error "java. io. file file = java. io. file (saveurl); String newSaveurl = request. getRealPath ("/") + url + filename + "_ min. "+ ext; Image image = javax. imageio. imageIO. read (file); tagSize = 200; oldWidth = image. getWidth (); oldHeight = image. getHeight (); width = 0 height = 0 tempdouble = 0 (oldWidth> = oldWidth/= oldHeight/= Math. round (oldWidth/= Math. round (oldHeight/= BufferedImage (width, height, BufferedImage. TYPE_INT_BGR); bufferedImage. getGraphics (). drawImage (image, 0, 0, width, height,); FileOutputStream newImage = FileOutputStream (newSaveurl); required imageencoder encoder = newImage. close (); response. sendRedirect ("index. jsp "" the file to be uploaded cannot exceed "+ (fileSizeMax/1024/1024) +" M"
Configuration File: web. xml
ImageLoadServlet com.servlet.ImageLoadServlet ImageLoadServlet /imageLoad index.jsp