What is possible is to extend a class. The directive is:
<%@ page extends="
package.class"%>
One reference for JSP page directives is: http://java.sun.com/products/jsp/tags/11/syntaxref11.fm7.html .
The class generated from a JSP usually extends
HttpServlet
. If you really want to have your JSP implement an interface, you could do something likemy.package.MyJSP
public abstract classextends HttpServlet implements
MyInterface{
}
... and then use "my.package.MyJSP" in a "page extends" directive as shown above.
The caveat to this is that some Web containers will generate their own subclasses of HttpServlet, presumably for some kine of optimization, and using the "page extends" directive will sabotage this scheme. It should still work, it just won't include the fancy footwork your Web container intended to do.
No comments:
Post a Comment