[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Are javabeans thread safe in a jsp environment?



I am a newbie as far as developing in Java. However, I want to create a simple web based application which will allow web users to update a database. I have apache2 and tomcat4 installed with mod_jk to provide the link between the two I think I want to use jsp as the main tactic for controlling the dynamic format for each page that I display, but provide "behind the scenes" logic in JavaBeans. There are two elements that I am not sure how I hold the information for. 1) Database connections - presumably taken from a connection pool Is it normal to store these in a bean? if so, do I declare the bean scope to be a page, request or a session (I forsee having to use <jsp:forward /> directives after using logic which needs to differnt things dependant on what is in the database. Are the properties of page/request/session scope beans thread safe? 2) Prepared sql statements I would like to have several of these to cover the main cases of querying the database. - do they need to be associated with connection - in which case I presume their life is only for the same life as the connection? - can they be cloned - ie so that I create them in a application scope bean and then copy them into the bean that has less scope?

I can't find any documentation which provides answers to these questions. It seems they are the sort of issue that has to be dealt with regularly in the development of web applications - so where would the standard answers be?
--
Alan Chandler
alan@chandlerfamily.org.uk


Reply to: