• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Servlet

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

Thanks for the replies!
 
Richard Rex
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks santosh for that info!
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where can we set the time for the init method to return ? Or is it default and Container dependent ?
 
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and what about the first option?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 )
 
Sheriff
Posts: 9704
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Enter into Time Machine -> Set time to April 24, 2006 -> Exit Time Machine

Richard please QuoteYourSources
 
Once upon a time there were three bears. And they were visted by a golden haired tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic