Question :How do I have the JSP-generated servlet subclass my own custom servlet
class, instead of the default? (JSP)
Answer :One should be very careful when having JSP pages extend custom servlet
classes as opposed to the default one generated by the JSP engine. In
doing so, you may lose out on any advanced optimization that may be
provided by the JSP engine. In any case, your new superclass has to fulfill
the contract with the JSP engine by:
Implementing the HttpJspPage interface, if the protocol used is HTTP, or
implementing JspPage otherwise Ensuring that all the methods in the
Servlet interface are declared final Additionally, your servlet superclass
also needs to do the following:
The service() method has to invoke the _jspService() method
The init() method has to invoke the jspInit() method
The destroy() method has to invoke jspDestroy()
If any of the above conditions are not satisfied, the JSP engine may throw
a translation error.
Once the superclass has been developed, you can have your JSP extend it
as follows:
<%@ page extends="packageName.ServletName" %<
www.interviewhelper.org is a hope for all the Job seekers. Users can find unlimited here. These range from technical to HR, from functional to behavioral. www.interviewhelper.org contains in the fields like Ajax,VB,Networking,Sharepoint,JEE,Perl,Javascript,Bioinformatics,Classic ASP,Unix,Linux,Accounting,Oracle DBA,Microprocessor,Bluetooth,jms,jme,.net framework,ABAP,ASP,ASP.net,Basic .net Framework,Interview Questions,C language,C++,database,Oracle,Java,PHP,LAMP,SAP etc.
Friday, March 13, 2009
How do I have the JSP-generated servlet subclass my own custom servlet
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment