nerdexam
Oracle

1Z0-899 · Question #164

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…

The correct answer is A. HttpServletRequest.getParts(). 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…

Servlets

Question

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?

Options

  • AHttpServletRequest.getParts()
  • BHttpServletRequest.getData()
  • CservletRequest.getParts()
  • DservletRequest.getAllParts()

How the community answered

(32 responses)
  • A
    78% (25)
  • B
    6% (2)
  • C
    13% (4)
  • D
    3% (1)

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.

Topics

#file upload#@MultipartConfig#getParts#multipart request

Community Discussion

No community discussion yet for this question.

Full 1Z0-899 Practice