Difference between _jspService() and other life cycle methods.

Last modified on July 25th, 2014 by Joe.

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.

Comments on "Difference between _jspService() and other life cycle methods."

  1. Satish Bakde says:

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

  2. ra says:

    nice explanation , some waht better….

  3. himanss says:


  4. Anonymous says:

    Very clearly documented. Very easy to understand

  5. Sanket says:

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

  6. sameep says:

    really nice explanation ……..

  7. Rupendra says:

    simple & nice explanation……..

  8. madhu says:

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

  9. ashok says:

    nice sir

  10. venu says:

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

  11. prakash says:

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

  12. paparao says:

    really good…..

  13. paparao k says:


  14. Anonymous says:

    crisp and clear..
    Thank You!

  15. tuhin says:

    fantastic… thanks joe.

  16. ajay says:

    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

  17. Syamala says:

    Very nice and easily understandable by anyone

  18. chaitu says:

    nice explanation !

  19. developer says:

    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?

  20. developer says:
  21. nitesh says:

    No Exception thrown…!!!

  22. A says:

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

  23. Ahte says:

    Really Joe it is awesome explanation by u.
    thanx joe

  24. Anonymous says:

    Great explanation, thanks – Siva

  25. ayushman says:

    out standing!!!!!!

  26. kishore says:

    JSP life cycle methods are:
    1.init(ServletConfig cg);

    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.

  27. Urmila says:

    nice explanation

  28. Anonymous says:


  29. prem says:

    Hi,you said only jspService method will have the prefix _(underscore) but I have developed my jsp and deployed in tomcat7 and when I try to see the generated servlet in work folder I have seen all the three methods have the prefix _(underscore),and we cannot override the methods like jspService() jspInit() method because the generated servlet is final so my doubt what is the use of _(underscore)
    Ihope I am waiting for your reply….

  30. Vikas chokhada says:

    Hi that was a great explantion all i wanted to know.


  31. Ram says:

    Nice & smart explanation

Comments are closed for "Difference between _jspService() and other life cycle methods.".