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

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

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 9707
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
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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9707
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

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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9707
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
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...
 
reply
    Bookmark Topic Watch Topic
  • New Topic