Accessing non-bean base class from JSP

I have an abstract base class that I use in several derived classes. I want to create one of these in a servlet, save the bits in the HttpSession and access the data from a JSP page using HttpServletRequest.getParameter(). Is it possible to make the derived class (defined in my WEB-INF/classes directory) visible to both a servlet and a JSP page without using a bean?

At this point I can use the derived class in a servlet and put the data in the session from there. No problem. I just can't figure out how to get it back out. I don't see how to get the .JSP file to recognize the class definition.

Normally I would just use a bean but I won't know in advance what type of derived class to expect in the JSP page. Hence the use of the abstract class def.

Message was edited by:

ethrbunny

[823 byte] By [ethrbunnya] at [2007-10-3 1:39:34]
# 1

If you don't know the type in advance, then you can't refer to the specific type. What I would do is this:

//in servlet

AbstractBaseType myClass = new RealType();

//...

session.setAttribute("myClass", myClass);

//in JSP

<jsp:useBean id="myClass" type="AbstractBaseType" scope="session"/>

I think that will get you where you want.

stevejlukea at 2007-7-14 18:37:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...