Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet Initialization Doubt ...

 
Vassili Vladimir
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

As i have understood from the HSFJ book, Servlet initialization is to instantiate the Servlet and call its init() method.

But in the The Java Server Pages (JSP) Technology Model mock exam of j2eecertificate, the following question :


Which of the following JSP page life-cycle phases occur before the container initialises a servlet instance? [Select all correct answers]

1call _jspService()
2load class
3create instance
4page translation
5call jspDestroy()



Is saying that answers 2, 3 and 4 are correct, but, from my understanding i have only chosen answers 2 and 4, which gave me a wrong answer

Please clear my doubts about Servlet initialization.

Thanks advance ...
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

After the JSP page is translated to Servlet, it is compiled, an instance is
created and then initialization is done.

Thanks,
 
Vassili Vladimir
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

So by initialization it is meant the actual calling of the jspInit() method ha ? If yes, then i got the point.

I do know the life cycle of JSP very well, but that point was not clear.

Thanks in advance ...
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vassili, creation of instance is a seperate process and initializing an instance is a seperate process. Please note!
 
Vassili Vladimir
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Jothi,

I know that each action is a separate process, but in the the HFSJ book, page 403, there's somewhere that's saying :


initializes a servlet (instantiates the servlet the calls init() on the new object)


This was the thing that made me ask and have a doubt.

So please clear my doubt about the mock question, by initialization it is meaning the actual invocation of the init() method right ?

Thanks in advance ...
 
Joshua Antony
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So please clear my doubt about the mock question, by initialization it is meaning the actual invocation of the init() method right ?

Yes that's correct!

Regards,
Joshua
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In servlets, initialization means running the init() method.
 
Vassili Vladimir
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks folks

Thanks alot

You guys have cleared my doubts

Best regards ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic