Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet

 
Richard Rex
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am doing a mock exam from one of the free available on the net and little bit confused with this...

Which two prevent a servlet from handling requests? Choose two.

A. The servlet's init method returns a non-zero status.
B. The servlet's init method throws a ServletException.
C. The servlet's init method sets the ServletResponse's context length to 0.
D. The servlet's init method sets the ServletResponse's context type to null.
E. The servlet's init method does not return within a time period defined by the servlet.
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

My answers are B and E.

If the init method throws the ServletException, or does not return in the perid set by container, the servlet cannot put into service by container.

Thanks
 
singh santosh
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Rex,
Which two prevent a servlet from handling requests? Choose two.

A. The servlet's init method returns a non-zero status.
B. The servlet's init method throws a ServletException.
C. The servlet's init method sets the ServletResponse's context length to 0.
D. The servlet's init method sets the ServletResponse's context type to null.
E. The servlet's init method does not return within a time period defined by the servlet.
--------------------


A servlet is not put to service if its initialization is not successful and is immediatley removed by the container .

Since ur option B,E indicates the unsuccessful intializtion of Servlet ,so according to me
option B,E should be the correct answer.

regards
-santosh
[ April 23, 2006: Message edited by: singh santosh ]
 
Richard Rex
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

Thanks for the replies!
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Santosh,

C. The servlet's init method sets the ServletResponse's context length to 0.
D. The servlet's init method sets the ServletResponse's context type to null.


There is no way to set the context length and context type in the init method. The ServletResponse object is available only in the service methods as a parameter to these methods.

Thanks
 
Richard Rex
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In what scenario can the Servlet's init method NOT return within a period of time? How is this done by the container?
 
singh santosh
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi narendra,
u r right. actually that was a mistake i intended for B,E only ,but i realized i have written B,D thats y i have immediatley edited my post

regards
-santosh
 
singh santosh
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi rex,
In what scenario can the Servlet's init method NOT return within a period of time? How is this done by the container?


There may be scenario like when the init method is using some Remote resource(may be some kind of i/O operations) for initialization purpose and which does not return on time .

regards
-santosh
 
Richard Rex
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks santosh for that info!
 
Yogesh Hingmire
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where can we set the time for the init method to return ? Or is it default and Container dependent ?
 
Ankur Jain Kothari
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and what about the first option?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The init method of a servlet does not return any value. It's return type is void.

(That's a very old thread you know )
 
Ankit Garg
Sheriff
Posts: 9577
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Enter into Time Machine -> Set time to April 24, 2006 -> Exit Time Machine

Richard please QuoteYourSources
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic