You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "David M. Holmes" <da...@yahoo.com> on 2000/08/10 21:48:05 UTC
Bean instantiation question
I have some beans that implement a base type. I would like to instantiate the correct type of bean
based on the request. The following will not work, "Variable 'ws' is already defined in this
method." Is there a way to do this?
<Dave/>
rateworksheets.RateWorksheet ws;
switch ( Integer.parseInt(request.getParameter("rate")) ) {
case 0:
%>
<jsp:useBean id="ws" class="rateworksheets.LGS" scope="request"/>
<%
application.getRequestDispatcher("/rateworksheets/reports/LGS.jsp").forward(request, response);
break;
case 1:
%>
<jsp:useBean id="ws" class="rateworksheets.MGS" scope="request"/>
<%
application.getRequestDispatcher("/rateworksheets/reports/MGS.jsp").forward(request, response);
break;
}
__________________________________________________
Do You Yahoo!?
Kick off your party with Yahoo! Invites.
http://invites.yahoo.com/