Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling jspInit() from servlet's init();

 
amarshi mohanty
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
In HFS page no. 344:It says that the jspInit() is called from the servlet's init() by the Container.But how will the container come to know that there is a jsp available so call its jspInit().
Because if there is no jsp available then the container just calls the servlet's init() passing servletconfig and servletcontext args.


Thanks
Amarshi Mohanty
 
Ankit Garg
Sheriff
Posts: 9579
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you create a JSP, your JSP is translated into a servlet which extends a base class which in-turn implement the HttpJspPage interface. The container calls the init method of the base class which calls the jspInit method. In tomcat, all JSPs extends from org.apache.jasper.runtime.HttpJspBase class. The init method of HttpJspBase class calls the jspInit method...
 
amarshi mohanty
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I am not wrong then the HttpJspBase class is implemented by the Vendor specific(Tomcat)---right?
So Tomcat's adds a line jspInit() inside the init() of HttpJspBase class.
Then why the book writes ServletConfig sConfig = getServletConfig();page:344
when the init() in HttpJspBase can call the jspInit() by passing the config parameter.



Thanks
Amarshi Mohanty
 
Ankit Garg
Sheriff
Posts: 9579
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I am not wrong then the HttpJspBase class is implemented by the Vendor specific(Tomcat)---right?
So Tomcat's adds a line jspInit() inside the init() of HttpJspBase class.

Yes. The vendor specific class' init method calls the jspInit method (see the soruce code of org.apache.jasper.runtime.HttpJspBase).

Then why the book writes ServletConfig sConfig = getServletConfig();page:344

The statement is not on page 344 in my book. Anyways, did you check the syntax of jspInit method in HttpJspBase interface?? The jspInit method doesn't take any parameters...
 
amarshi mohanty
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I am using HFSJ 2nd edition e-book. I have those lines in pag:344.
Its under heading:Initializing your JSP and subheading Overriding jspInit().
 
Ankit Garg
Sheriff
Posts: 9579
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay I found it, its on page 310 in my book. Mine is also HFSJ second edition (Indian edition). Anyways, is your doubt solved or not??

PS: that page has a few errors, find the text "page 310" on the errata page...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic