Skip to main content

Posts

Showing posts with the label jee

JEE File Upload - Handling Multipart requests in Servlets 3.0

Prior to Servlets 3.0 developers have to use 3rd party libraries to process complex multipart request that is sent when file is uploaded by user. Starting from Servlets 3.0 JEE provides a better way to handle file uploads (multipart requests) without using any 3rd party library. Making your Servlet ready to handle Multipart requests All you have to do is to add  @MultipartConfig annotation on your servlet class and it is ready to handle Multipart requests. @MultipartConfig   public class FileUploadServlet extends HttpServlet { Our example HTML form <form method="POST" enctype=" multipart/form-data "> <input type="file" name="ufile" /> <input type="submit" value="Submit" /> </form> Handling the POST in processRequest method of Servlet protected void processRequest (HttpServletRequest request,         HttpServletResponse response)         throws ServletException, IOException { Gettin...