Which method should the servlet use to access the uploa…

A web application for business expense reporting allows uploading expense receipts. Multiple receipts can be uploaded single step using one HTTP request. The
servlet that processes the request has been marked with the @MultipartConfig annotation. Which method should the servlet use to access the uploaded files?

A web application for business expense reporting allows uploading expense receipts. Multiple receipts can be uploaded single step using one HTTP request. The
servlet that processes the request has been marked with the @MultipartConfig annotation. Which method should the servlet use to access the uploaded files?

A.
HttpServletRequest.getParts()

B.
HttpServletRequest.getData()

C.
servletRequest.getParts()

D.
servletRequest.getAllParts()

Explanation:
The request.getParts() method returns collections of all Part objects. If you have more than one input of type file, multiple Part objects are returned. Since Part
objects are named, the getPart(String name) method can be used to access a particular Part. Alternatively, the getParts() method, which returns an Iterable<Part>,
can be used to get an Iterator over all the Part objects.



Leave a Reply 2

Your email address will not be published. Required fields are marked *