• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

EPractice Lab mock exam 1 question 6

 
Ranch Foreman
Posts: 1900
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


EPractice Lab Online Skill Evaluation Lab uses descriptive type questions to support image and text answer input. Examinee can also draw and upload their images from local system. To support this requirement a developer decided to use Java Servlet.
Which of the following statements about the client request and the servlet are true, considering request is of type HttpServletRequest?

A. The client request can be either "GET" or "Post"
B. The method request.getReader() should be used to retrieve the file data.
C. The client request must be Post
D. The method request.getInputStream() should be used to retrieve the file data.
E. The method request.getParameterValues(String reqParameter) should be used to retrieve the file data.
Answers : C, D

Explanation:
C, D
"Get" uses the URL to transfer the parameters and hence can be used only for textual data. Also the amount of data that can be sent by "Get" is limited. On the other hand "POST" uses the body of the request to send the data and there is no limit in the size of the data that can be transferred. So, "POST" is ideal for file uploads.

The servletRequest has the following two methods, which can be used to read the body of the request:
BufferedReader getReader() : Retrieves the body of the request as character data using a BufferedReader
ServletInputStream getInputStream(): Retrieves the body of the request as binary data using a ServletInputStream.
For file uploads, the encoding type of the request should be specified as "multipart/form-data". The container will populate the parameter map only when the encoding type is "application/x-www-form-urlencoded" (which is the default when encoding type is unspecified.)



I think the answer should be A, D.
The question is the examinee can draw images. It means the examinee can get image from the local system.
When we request for data using doGet, we can put a query string like this http://localhost:8080/myImageContext/myImageRetriever?filename=myPicture.
We don't need to put a large amount of data in the query string in the request URL.


 
Bartender
Posts: 322
24
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Himai Minh wrote:When we request for data using doGet, we can put a query string like this http://localhost:8080/myImageContext/myImageRetriever?filename=myPicture.
We don't need to put a large amount of data in the query string in the request URL.


That's true, but the question is not referring to downloading an image. The question explicitly says the Examinee (the user) can draw and upload their images.

EPractice wrote:Examinee can also draw and upload their images from local system.

 
    Bookmark Topic Watch Topic
  • New Topic