• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question form the mock test

 
trupti nigam
Ranch Hand
Posts: 627
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What HTTP method and the corresponding HttpServlet method is used when a user clicks on the Submit button of a FORM used for capturing username/password?
GET & doGet(HttpServletRequest req,HttpServletResponse res)
POST & doPost(HttpServletRequest req,HttpServletResponse res)
PUT & doPut(HttpServletRequest req,HttpServletResponse res)
OPTIONS & doOptions(HttpServletRequest req,HttpServletResponse res)
I think GET & doGet
But the answer given is POST & doPost
Below is the explanation given in the mock test:
Although the default method for FORM is GET but for capturing a username/password, almost always (and specially for username/password), POST method is used. This ensures that the parameters and the values do not become a part of the url.
but I have read it in book that if the method is not specified then by default it is "GET" . Then why POST is called?
thanks
Trupti
 
Andre Mermegas
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question is worded vaguely for sure, but the assumption is that all forms will be using POST, I guess.
Since there is no code shown,its a toss-up.
You are right by default unless POST is specified GET is the default method.
 
Prasad Charasala
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question should be like this
"What HTTP method and the corresponding HttpServlet method is used for capturing username/password?"
It is a general practice to use POST & doPost method for security reasons to submit userid & password.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic