aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Servlet Lifecycle Doubt? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Servlet Lifecycle Doubt?" Watch "Servlet Lifecycle Doubt?" New topic
Author

Servlet Lifecycle Doubt?

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Ranchers,

Say for example when we don't have a servlet initialized during container startup and when we request for a servlet, the container creates a request and response object. I want to know which one is created first, the servlet instance or the request and response instance?? Can anyone comment on this?


SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
Saurabh Kumar
Ranch Hand

Joined: Aug 21, 2006
Posts: 56
The container instantiates a servlet either on startup(if specified) or on first request. So, I think it creates the request, response objects first and then the servlet instance if the servlet if already not loaded.

Am I right, ranchers?

Thanks and regards,
Saurabh
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Anyone to support Saurabh?? Any convincing answers for me???
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39578
    
  27
I think a more interesting question to ask would be: does it matter whether request/response or servlet are initialized first?


Ping & DNS - updated with new look and Ping home screen widget
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

So does it really matter ulf?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39578
    
  27
Well, you are the one preparing for the SCWCD (I assume)

Does it matter? If so, why? If not, why not?
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Bemused. I just wanted to know this out of curiosity...which instance is created first...the request/response or the servlet instance?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18155
    
    8

Well, look. Tomcat is open source. So you could get the source code of Tomcat and answer this question for yourself in the Tomcat context. That's not to say that Websphere or JBoss or any of the other servers do the same thing, though. I think we are all bemused why you care about this question.

My usual question is "What would you do differently based on the answer to this question?" but I try to avoid posting that in the certification forums, where it doesn't apply. However in this case I don't think the question is going to be asked on any certification exam, so perhaps it could be asked.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Paul, I know that this is a silly or rather irrelevant question, but I just wanted to know out of curiosity. Anyways thanks to all the ranchers who participated in this debate. Thanks again!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet Lifecycle Doubt?
 
Similar Threads
Life cycle of a servlet
Servlet loading and servlet instacne
Set me straight on synchronization for stateless bean
How servlet process multiple request.
Servlet Container