Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet Lifecycle Doubt?

 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Saurabh Kumar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone to support Saurabh?? Any convincing answers for me???
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think a more interesting question to ask would be: does it matter whether request/response or servlet are initialized first?
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So does it really matter ulf?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bemused. I just wanted to know this out of curiosity...which instance is created first...the request/response or the servlet instance?
 
Paul Clapham
Sheriff
Posts: 21126
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic