Bug 58444 - _jspInit() never called on JSP with custom super class
_jspInit() never called on JSP with custom super class
Status: RESOLVED FIXED
Product: Tomcat 7
Classification: Unclassified
Component: Jasper
unspecified
All All
: P2 normal (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2015-09-22 10:15 UTC by Stephan
Modified: 2015-09-22 18:54 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan 2015-09-22 10:15:30 UTC
I have a JSP that extends a custom super class:

<@page extends="com.example.MySuperServlet" %>

My super class is defined as follows:

public abstract class MySuperServlet extends javax.servlet.GenericServlet implements javax.servlet.jsp.HttpJspPage {
  @Override public void service(....) {
    _jspService(req, res);
  }
  @Override public void jspInit() {}
  @Override public void jspDestroy() {}
}


The problem is that the generated JSP class contains a method _jspInit() which is never called.
It initializes an expression factory (_el_expressionfactory) and an instance manager (_jsp_instancemanager).
Now that both are not initialized, I get NullpointerExceptions when calling the JSP, i.e. in some generated methods there is code like
_jsp_instancemanager.newInstance(_jspx_th_my_005fcustomtag_005f0)

Usually when there is no custom super class, tomcat extends the generated JSP class from org.apache.jasper.runtime.HttpJspBase which calls _jspInit() from its init(ServletContext) method.

For my custom super class it is no option to extend org.apache.jasper.runtime.HttpJspBase instead of GenericServlet because it is tomcat specific.
It is also no option to call _jspInit() directly from my jspInit() method, because _jspInit() is not part of the servlet/JSP spec and thus it is not defined in any interface.

Note that there is no problem with tomcat 6 and 5.

I haven't tested with tomcat 8, yet.
Comment 1 Mark Thomas 2015-09-22 14:57:31 UTC
7.0.x, 8.0.x and trunk all suffer from the same problem.

I have a fix for trunk that I'll commit shortly and then I'll work on back-porting the fix to 8.0.x and 7.0.x.
Comment 2 Mark Thomas 2015-09-22 18:54:00 UTC
Fixed in 8.0.x for 8.0.27 onwards and in 7.0.x for 7.0.65 onwards.