Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Confusion about overriding jsp equivalent init()  RSS feed

Ranch Hand
Posts: 774
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Here is a exam watch from david bridge water book and i am unable to understand what it means, please help

If you want to harness jspInit() and jspDestroy() for your own setup and tear-down processes,
you can—by overriding either or both in a JSP declaration, which we explore a little later in this chapter. What if you
decided to override the servlet equivalents, init(ServletConfig config) and destroy()? Well, the JSP spec says
you can’t and mustn’t do this. Most JSP container providers prevent this happening by making all Servlet interface methods
fi nal in the base JSP servlet that they provide—your generated JSP servlet that inherits from this can’t possibly override
them. And while on the subject of overriding, you can’t override _jspService() either. This method represents your page source
in Java code form—it’s up to the clever container’s page generators to worry about the implementation and generation of this
method for each individual JSP. It makes no sense for you to override it within the JSP page itself.

Any points would be helpful.
Creator of Enthuware JWS+ V6
Posts: 3241
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Prithvi,

It just tells you that (if you really want to) you can override the jspInit() and jspDestroy() methods but you can't override the Servlets equivalents (although a JSP is a Servlet). Furthermore remember that your JSP is generated into a Servlet, and this is what the API tells you:

The _jspService()method corresponds to the body of the JSP page. This method is defined automatically by the JSP container and should never be defined by the JSP page author.

All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!