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 are closed for "Difference between _jspService() and other life cycle methods.".
Wonderfull explaination. I never thought this way. Thanks buddy.
nice explanation , some waht better….
gud
Very clearly documented. Very easy to understand
So nicely explained. Sweet and short. Hearty thanks for it.
really nice explanation ……..
simple & nice explanation……..
I got easily. please explain everything like that.U done great job
nice sir
wonderful blog sir,,,, i never saw this type of blog………..
awesome !! really your blogs clears the concept, Sir please update about method overriding with example.
really good…..
good
crisp and clear..
Thank You!
fantastic… thanks joe.
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
Very nice and easily understandable by anyone
nice explanation !
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?
No Exception thrown…!!!
what is the exact reason due to which we can not override _jspService() method. ??
Really Joe it is awesome explanation by u.
thanx joe
Great explanation, thanks – Siva
out standing!!!!!!
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.
nice explanation
gud
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….
Hi that was a great explantion all i wanted to know.
Thanks
Nice & smart explanation