• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Pg. 143 Head First book

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I just had a doubt about question no:8 on pg. 143.

"Which methods are used by a servlet to handle form data from a client?"(Choose all that apply)

A. HttpServlet.doHead()
B. HttpServlet.doPost()
C. HttpServlet.doForm()
D. ServletRequest.doGet()
E. ServletRequest.doPost()
F. ServletRequest.doForm()

The answer is given as option "B".

Shouldn't the answer be option "D" (ServletRequest.doGet) b'cos by default a form is said to call the doGet() method in the servlet(when the 'submit' is clicked)?

Can somebody please explain why the answer is stated as "B"?
Thanks,
Jayanthi.
 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question probably should have been "Which method should be....."

Because for to process Form data which has many fields, it would be more convinient to process it to POST method as GET involves a restriction of 255 characters.
 
Bartender
Posts: 3729
39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jayanthi Mani:
Hello,
I just had a doubt about question no:8 on pg. 143.

"Which methods are used by a servlet to handle form data from a client?"(Choose all that apply)

A. HttpServlet.doHead()
B. HttpServlet.doPost()
C. HttpServlet.doForm()
D. ServletRequest.doGet()
E. ServletRequest.doPost()
F. ServletRequest.doForm()

The answer is given as option "B".

Shouldn't the answer be option "D" (ServletRequest.doGet) b'cos by default a form is said to call the doGet() method in the servlet(when the 'submit' is clicked)?

Can somebody please explain why the answer is stated as "B"?
Thanks,
Jayanthi.



Jayanthi,

The 'ServletRequest' does not have doXXXX methods, so 'D' option is wrong



regards,
MZ
 
Jayanthi Mani
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Mikalai! That explains it better now....
 
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

The way the mock questions are phrased makes it tougher than the real exams. Although the question told us to choose all that apply & methods had an 's', its really meant to test our understanding & whether we read the APIs.

In the real exams, we'll be told exactly how many correct answers they would be. This make our life easier. But if you could get pass those trick questions in the mock, I guess you're pretty safe in the real exams.

HTH.

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.

I know it is an old topic but since it is the only one I found on the forum that address to my following question...


The thing is, if we strictly think about the possibility to or not to handle 'form data' in a servlet, I see nothing wrong about letter A, which states doHead() from HttpServletRequest. I mean, isn't possible to get parameters and then process them when we are handling a doHead() ? If so, for me both A and B seem to be right answers.
 
Creator of Enthuware JWS+ V6
Posts: 3395
312
Android Eclipse IDE Chrome
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Icaro,

The thing is, if we strictly think about the possibility to or not to handle 'form data' in a servlet, I see nothing wrong about letter A, which states doHead() from HttpServletRequest. I mean, isn't possible to get parameters and then process them when we are handling a doHead() ?


You can only submit form data with the method "get" and "post", like:

See also w3schools

It won't accept other methods like "head", that is why A is not correct.

Regards,
Frits
 
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Assume that Option G : HttpServlet.doGet() is given as a choice. In that case, the answer will be both Option B and G [OR] just Option B ?
 
reply
    Bookmark Topic Watch Topic
  • New Topic