Why can't the jspService()
method be overridden, where as jspInit()
and jspDestroy()
can be overridden?
Why ? Since what ever we wrote code in the JSP will be placed in _jspService() of generated servlet class(from JSP) . means _jspService() is already imlimented by us.So if we attempted to override _jspService() it will give a compilation error regarding the method _jspService() is already defined.
_jspService() method is used to serve the raised requests by JSP. It takes request and response objects as parameters. This method cannot be overridden.
This forum post explains why you cannot override jspService().
Basically, if you tried to override the jspService method, the code generated by the JSP compiler would end up with two copies of the method: the one you wrote and the one created by the compiler. This would result in a Java compilation error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With