Difference between _jspService() and other life cycle methods.

05/05/2008

JSP contains three life cycle methods namely jspInit( ), _jspService() and jspDestroy(). In these, jspInit() and jspDestroy() can be overridden and we cannot override _jspService().

The contents what we write in the JSP will go into _jspService() because we are implicitly implementing it. If we again try to override it explicitly, JSP compliler will giver error as ‘the method is already implemented and cannot override’. But in the case of other two methods we are not implementing it in the JSP. Therefore the JSP compiler will allow to override jspInit() and jspDestroy().

To show this difference _jspService() method is prefixed with ‘_’ by the JSP container and the other two methods jspInit() and jspDestroy() has no special prefixes.

Ads by Google

28 comments on “Difference between _jspService() and other life cycle methods.

  1. Wonderfull explaination. I never thought this way. Thanks buddy.

  2. Very clearly documented. Very easy to understand

  3. So nicely explained. Sweet and short. Hearty thanks for it.

  4. I got easily. please explain everything like that.U done great job

  5. wonderful blog sir,,,, i never saw this type of blog………..

  6. awesome !! really your blogs clears the concept, Sir please update about method overriding with example.

  7. If some one ask any topic try to cover all related issue.Its good if u also describe diff b/w jspInt() and _jspInt(),also explain where the scriptlet code go and whrere the declaration code go

  8. Very nice and easily understandable by anyone

  9. Hi Joe,

    I tried to create one jsp in which I wrote one method with the name butit got complied and work perfectly..so I am confused here.

    Please let me know why it worked?

  10. what is the exact reason due to which we can not override _jspService() method. ??

  11. Really Joe it is awesome explanation by u.
    thanx joe

  12. JSP life cycle methods are:
    1.init(ServletConfig cg);
    2.service(-,-);
    3.destroy()

    these are the JSP life cycle methods same as servlet life cylce methods!

    The life Cycle of Convience methods are:
    —————————————-
    1.jspInit()–>for init(-)
    2._jspService(-,-)—>for service(-,-)
    3.jspDestroy()—>for destroy()

    these becoz of every JSP program internally executes as an equivalent servlet prg.but jsp api gives different life cycle convience methods.

    for more information contact
    dkishore.mails@gmail.com

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

ABOUT
I am Joe, author of this blog. I run javapapers with loads of passion. If you are into java, you may find lot of interesting things around.
Ads by Google
STAY in TOUCH:

Email:

Core Java | Servlet | JSP | Design Patterns | Android | Spring | Web Service | © 2008-2012 javapapers.