File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Selecting which bean to use Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Selecting which bean to use" Watch "Selecting which bean to use" New topic

Selecting which bean to use


Joined: Jul 26, 2001
Posts: 1
I am generating a generic/dynamic form for multiple database tables. Is there a way of selecting which bean or java code to use depending on the table?
<jsp:useBean id='object' scope='page' class='<%= classname%>'
<jsp:setProperty name="object" property="*"/>
This code doesn't work. Is there another way of doing this either in the JSP or a bean.
Please help - its driving me mad!!!
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

your name doesn't seem to agree with the javaranch guidelines.
please take a moment and re-register after reviewing the
guidelines at
thanks for your cooperation.
- satya

Take a Minute, Donate an Hour, Change a Life
Sam Dalton
Ranch Hand

Joined: Jul 26, 2001
Posts: 170
Try writing a custom tag to do this. You can then put whatever bean you want back into the session/request.
You should be able to find an example of this in any elementary JSP book.
Also see the JavaOne presentations on my website.

If you want more info please post again.

<a href="" target="_blank" rel="nofollow">Sam Dalton</a>,<br />Co-author of []Professional JSP 2.0[/URL] (October 2003)<br />Co-author of <a href="" target="_blank" rel="nofollow">Professional SCWCD Certification</a><br />Co-author of <a href="" target="_blank" rel="nofollow">Professional Java Servlets 2.3</a>
I agree. Here's the link:
subject: Selecting which bean to use
It's not a secret anymore!