D
Dave
I have implemented the J2EE abstract factory DAO pattern for accessing data
in my application. This works well in my Java application.
http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html
I am, however, having problems using this with my JSP page. As objects are
typically instantiated using the <jsp:usebean...> tag in JSP, and this
instantiates with a default constructor how do I use this pattern with my
JSP page?
In my Java application I use code along the lines of:
/* The DAOFactory should be instantiated once only! */
DAOFactory daoFactory = DAOFactory.getDAOFactory(DAOFactory.SQLSERVER);
PersonDAO personDAO = daoFactory.getPersonDAO();
Person person = personDAO.getPerson(1234);
I *cannot* instantiate a DAOFactory object using <jsp:usebean..> because it
is an abstract class. I also *cannot* instantiate a PersonDAO object without
using the factory as it is an interface.
My initial thoughts are to use some sort of intermediate wrapper class that
instantiates the DAOFactory and handles requests. Is this the standard way
to handle this problem?
Any suggestions would be appreciated.
in my application. This works well in my Java application.
http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html
I am, however, having problems using this with my JSP page. As objects are
typically instantiated using the <jsp:usebean...> tag in JSP, and this
instantiates with a default constructor how do I use this pattern with my
JSP page?
In my Java application I use code along the lines of:
/* The DAOFactory should be instantiated once only! */
DAOFactory daoFactory = DAOFactory.getDAOFactory(DAOFactory.SQLSERVER);
PersonDAO personDAO = daoFactory.getPersonDAO();
Person person = personDAO.getPerson(1234);
I *cannot* instantiate a DAOFactory object using <jsp:usebean..> because it
is an abstract class. I also *cannot* instantiate a PersonDAO object without
using the factory as it is an interface.
My initial thoughts are to use some sort of intermediate wrapper class that
instantiates the DAOFactory and handles requests. Is this the standard way
to handle this problem?
Any suggestions would be appreciated.