I use a properties file instead of using switch statement:

        change_user_info=ChangeUserInfo

change_user_info is the value of hidden variable
ChangeUserInfo is the JAVA class.

next are the codes which create the objects:

            String actionClass = prop.getProperty( action );
                Class cls = Class.forName(actionClass);

            Object obj = cls.newInstance();

            AbstractFormAction abstractFormAction =
( AbstractFormAction )obj;

            abstractFormAction.setSessionData( httpSessionData );

                // do whatever

action is the value of hidden variable.
AbstractFormAction is a super class for all factory objects.
httpSessionData is a object which holds the necessary data( like properties,
httpRequest, httpResponse and etc. )

Haiying Qiao

-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Mike Engelhart
Sent: Tuesday, November 16, 1999 9:25 AM
To: [EMAIL PROTECTED]
Subject: Servlets and Factories


Hello -
I'm seeking advice on using Factory objects in my Servlets.  Currently my
servlets are instantiating and stuffing Beans that get passed to my JSP's
for display.   As my servlets are getting a little long in tooth, I've been
wanting to rewrite my servlets to use factory objects to create the beans
for me and return the reference to the calling servlet.  Currently I'm using
a switch statement in my servlets which get passed a hidden field which
determines what the servlet should do.   This is less than ideal :-)

I'm wondering if anyone has any advice on how to easily do this with the
factory objects.  Are developers passing HttpServletRequest objects to your
factories?  What about JDBC connection objects and other shared servlet
resources?  As I have a large number of shared resources, I was wondering if
developers are passing a ServletContext reference in to handle this or what
the preferred methods are.

Thanks for any advice.

Mike

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to