cancel
Showing results for 
Search instead for 
Did you mean: 

Extend JSP from superclass not working correctly ?

Former Member
0 Kudos

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 -


Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

see thread for more information. Currently, this is a known problem, which should be fixed in future SPs of the J2EE Engine.

Former Member
0 Kudos

Hi Ivaylo,

do you have an idea when this SP will be released ? Is it possible to get a quicker fix instead of a SP ?

best regards,

Matthias Hlubek

Former Member
0 Kudos

Hi Matthias,

can't really say which SP will solve the issue. If you open a customer OSS message about the problem, you'll surely get the fix earlier (not bound to any SP timeframes).. So, I'd suggest that you go this way.

Best regards,

Ivo