|
1 | | -package com.baeldung.javaeeannotations; |
2 | | - |
3 | | -import java.io.IOException; |
4 | | - |
5 | | -import javax.servlet.ServletException; |
6 | | -import javax.servlet.annotation.MultipartConfig; |
7 | | -import javax.servlet.annotation.WebServlet; |
8 | | -import javax.servlet.http.HttpServlet; |
9 | | -import javax.servlet.http.HttpServletRequest; |
10 | | -import javax.servlet.http.HttpServletResponse; |
11 | | -import javax.servlet.http.Part; |
12 | | - |
13 | | -@WebServlet(urlPatterns = { "/uploadCustDocs" }) |
14 | | -@MultipartConfig( |
15 | | - fileSizeThreshold = 1024 * 1024 * 20, |
16 | | - maxFileSize = 1024 * 1024 * 20, |
17 | | - maxRequestSize = 1024 * 1024 * 25, |
18 | | - location = "D:/custDocs" |
19 | | - ) |
20 | | -public class UploadCustomerDocumentsServlet extends HttpServlet { |
21 | | - |
22 | | - protected void doPost( |
23 | | - HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
24 | | - for (Part part : request.getParts()) { |
25 | | - part.write("myFile"); |
26 | | - } |
27 | | - } |
28 | | - |
29 | | -} |
| 1 | +package com.baeldung.javaeeannotations; |
| 2 | + |
| 3 | +import java.io.IOException; |
| 4 | + |
| 5 | +import javax.servlet.ServletException; |
| 6 | +import javax.servlet.annotation.MultipartConfig; |
| 7 | +import javax.servlet.annotation.WebServlet; |
| 8 | +import javax.servlet.http.HttpServlet; |
| 9 | +import javax.servlet.http.HttpServletRequest; |
| 10 | +import javax.servlet.http.HttpServletResponse; |
| 11 | +import javax.servlet.http.Part; |
| 12 | + |
| 13 | +@WebServlet(urlPatterns = { "/uploadCustDocs" }) |
| 14 | +@MultipartConfig( |
| 15 | + fileSizeThreshold = 1024 * 1024 * 20, |
| 16 | + maxFileSize = 1024 * 1024 * 20, |
| 17 | + maxRequestSize = 1024 * 1024 * 25, |
| 18 | + location = "D:/custDocs" |
| 19 | + ) |
| 20 | +public class UploadCustomerDocumentsServlet extends HttpServlet { |
| 21 | + |
| 22 | + protected void doPost( |
| 23 | + HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
| 24 | + for (Part part : request.getParts()) { |
| 25 | + part.write("myFile"); |
| 26 | + } |
| 27 | + } |
| 28 | + |
| 29 | +} |
0 commit comments