Is it possible to have a jsp page determine which bean to use at run time?
Created May 4, 2012
Mad Man The above scenario can be implemneted but not through jsp:useBean element.
Checkout the following example which will instantiate the bean based on the condition.
<% String stateCode = request.getParameter("state"); %> <% if ( stateCode.equals("CA") ) { Bean1 bean1Obj = new Bean1(); %> <%= bean1Obj.sayHello() %> <% } else { Bean2 bean2Obj = new Bean2(); %> <%= bean2Obj.sayHello() %> <% } %>