Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JwebPlus:Question ID :994872851531

 
Vikrama Sanjeeva
Ranch Hand
Posts: 760
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question ID :995549757220
Following is the code for LoginServlet. Assuming that it is not preloaded or preinitialized, which of the given statements about it are correct?
(Statements given below are regarding the methods defined in this class.)
//[code]
public class LoginServlet extends HttpServlet
{
public void init()
{
//initialize db.
}
public void doGet(HttpServletRequest req, HttpServletResponse res)
{
//do something
}
public void doPost(HttpServletRequest req, HttpServletResponse res)
{
//do something
}
}
//[code]

ANS: for any HTTP request, at most two of its method will be called.
I have confusion.Just think if any other HTTP request(except doGet & do Post) is made then how will at most two methods will be called(from methods defined in this class)
Bye.
Viki.
 
ersin eser
Ranch Hand
Posts: 1072
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This one and the the one almost sounds like this one from jweb+ are badly worded questions, don't sweat & worry about them! If you understand what functions called when, that is good enough. You won't get strangely-worded questions like this one.
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3817
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, at most two does not mean always two. However, I agree that the statement should be improved. Any suggestions?
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
first init() will be called for sure.
for rest of the code, what i think is, as they haven't given doPut() etc method's implementations it will give error for those invocations. but otherwise it will call doGet() or doPost() depending upon the request type. so that makes it max. 2 method calls (either init() only or init() and doPost()/doGet()). if they had given service() method implemented then it would have been at most 3 method calls and atleast 2 (i guess so).
regards
maulin.
 
Vikrama Sanjeeva
Ranch Hand
Posts: 760
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, i think it is now concluded that if any of the doPut() doDelete or doOptions() will be made as a request then at most two methods will not be called(from methods defined in this class).

At least Two:.....I disagree.Consider a scenario where there NO request is made.
Bye.
Viki.
 
Scott Ramsey
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My 2 cents...
I disagreed with this question's answer as well.
By my reckoning, up to four methods could be called if this is the very first HTTP request for this servlet:
1. constructor (not pre-loaded)
2. init() (not pre-initialized)
3. service()
4. doXXX()
(Shameless plug:
For the record, while I did encounter a few of these vague or incorrect questions (as well as a SLEW of syntax errors! e.g. it's HttpSessionAttributeListener, singular, not AttributeSListener) JWeb's mock exam tool, I can say it helped prepare me quite well for the exam. I read the specs through, and then did a custom test in JWEb that gave me every question it had for each section. After taking these exams, I reviewed every answer on each question and went back and forth in the specs to verify and investigate. A bit tedious, but it didn't take more than a couple days and was extremely helpful in showing important concepts.
I only missed four questions on the real exam.)
Thanks.
 
Vikrama Sanjeeva
Ranch Hand
Posts: 760
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the question carefully....it says..in bracket

(Statements given below are regarding the methods defined in this class.)

What i think: is that don't consider even the inherited methods.B/C they are not defined in this class.
Well, can u tell me what was ur score in standard test of JWebplus.?
Bye.
Viki.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi viki,
sorry, i forgot to think about "when there is no call to any method". but i didnt 've a full question and so i guessed they r talking when they call SOME method ya, but u r right. and i also agree with ur last post that it asks about methods that are being "implemented" and shown in the code.
regards,
maulin.
 
Vikrama Sanjeeva
Ranch Hand
Posts: 760
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

but i didnt 've a full question

Its full question.I have just copy-paste it(Life is so easy )
Bye.
Viki.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic