Hi,
I'm currently developing a simple 2.5-tier application using the Model 2
architecture, with a controller/session servlet, "regular" JavaBeans to
model logic and control db access, and JSPs for display. I'm new to this and
have a few questions:
1. Initially the entire application will run on the web server, on the same
machine as the db server. However, I foresee that in the future we may want
to use an appserver and Enterprise JavaBeans for the application logic. What
can I do in designing my regular beans today, that they will be easier to
replace with EJBs in the future? This may be more of a system architecture
question than about the interfaces my beans expose.
2. It might help and it seems to me a better separation of business-logic,
site-logic and presentation-logic, if the beans control database access. I'd
like to use a connection pool, like the DBConnectionBroker from
http://www.javaexchange.com/ <http://www.javaexchange.com/> . How can a
bean, instead of a servlet, maintain such a pool over the life of the
application in an elegant way, and how can another bean somewhere else in
the application get/free a connection from the dbpool bean, without the
controller servlet and JSPs ever needing to know about it?
3. Since Servlets and JSP are executed as multiple threads, what are the big
concurrency gotchas that I should look out for? I've read someplace that it
is quite common for database query methods to implemented as static methods
to cut creation overhead and to increase execution speed. Is this
thread-safe as long as all fields the static method manipulates are either
passed in as parameters or are local fields, as opposed to static class
fields, or instance member fields? For example, can a static method create a
new result/view bean on the fly and return it to the method caller without
the data being corrupted by other threads or causing a race condition?
4. Is anybody reusing PreparedStatements in their Servlet/JSP/JavaBean
applications, or is it more work and memory than it is worth?
Thanks,
Scott
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets