on 01-24-2006 4:07 PM
Hi all,
i have got an issue extending a JSP from my superclass in order to do a pre- and postprocessing of a JSP. It looks like the service() method implementation of my superclass is not executed by the SAP J2EE JSP_ENGINE. Below you can find a example source code based on the JSP 1.2 specification which demonstrates the issue. Do I something wrong or do i have to configure something in the J2EE engine ?
I hope someone can help me.
regards Matthias Hlubek
-
Snipp----- ExampleHttpSuper -
package com.test;
import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.HttpJspPage;
/**
An example of a superclass for an HTTP JSP class
*/
public abstract class ExampleHttpSuper implements HttpJspPage {
private ServletConfig config;
final public void init(ServletConfig config) throws ServletException {
this.config = config;
jspInit();
System.out.println("INIT JSP");
}
public void jspInit() {
}
public void jspDestroy() {
}
final public ServletConfig getServletConfig() {
return config;
}
// This one is not final so it can be overridden by a more precise method
public String getServletInfo() {
return "A Superclass for an HTTP JSP"; // maybe better?
}
final public void destroy() {
jspDestroy();
}
/**
The entry point into service.
*/
final public void service(ServletRequest req, ServletResponse res)
throws ServletException, IOException {
// casting exceptions will be raised if an internal error.
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
this.preservice();
_jspService(request, response);
this.postservice();
}
/**
abstract method to be provided by the JSP processor in the subclass
Must be defined in subclass.
*/
abstract public void _jspService(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException;
public void preservice(){
System.out.println("Before");
}
public void postservice(){
System.out.println("After");
}
}
-
Snipp----- ExampleHttpSuper -
-
Snipp----- JSP -
<%@ page language="java" extends="com.test.ExampleHttpSuper" %>
<html>
<head>
<title>
Title
</title>
</head>
<body>
<h1>
Generated JSP
</h1>
</body>
</html>
-
Snipp----- JSP -
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
75 | |
10 | |
10 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.