Hi all,
I have three beans implementing a common interface.
I wish to use a reference to the interface in my jsp.

The first page (setting the request params) looks like this

    PriceHandlerIF priceHandler = null;
    String primaryKey = null;
    String beanClass = request.getParameter ( "bean" );
    try {
         if ( beanClass.equals ( "Tour" ) ) {
            primaryKey = request.getParameter ( "tourKey" );
            priceHandler = Tour ();
            ((Tour)priceHandler).setFieldsMap ( DBHandler.retrieve ( new
Tour(), primaryKey ) );
        }
    }
    catch ( DataBeanNotFoundException dbnfe ) {
%>
<jsp:forward page="index.jsp" />
<%
    }
%>


I tried useBean on the first page but couldn't seem to get it working.
In the second page (request handler)I just put the class into scope with
pageContext.setAttribute like this.

<%@page contentType="text/html"
        import= "au.org.mena.domain.System
                        au.org.mena.database.*"
%>
<%
    pageContext.setAttribute ( "priceHandler", Class.forName (
request.getParameter ("beanClass") ) );
%>

<jsp:useBean    id="priceHandler"
                type="au.org.mena.domain.PriceHandlerIF" />
<jsp:setProperty name="priceHandler" property="*" />
<%
    DBHandler.update ( priceHandler );
%>
<jsp:forward page="index.jsp" />

Unfortunately the servlet wants to instantiate a PriceHandler which doesn't
work.

Is there an easy way to use interfaces in JSP (without having the object
instatiated and in scope first)??

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to