Hi,

I had a look at your code. SimpleBean1 is not a servet but it makes use of the
Servlet session tracking API. I think your desgn structure is fundamentally
flawed.

Emmanuel Eze

Quoting Brett Zamora <[EMAIL PROTECTED]>:

> Hi...
>
> I'm trying to build a JSP/Servlet application that will retrieve, add,
> update, and delete records from a database. I've recently encountered some
> of the complications that can be seen if a servlet is not written to be
> thread safe.
>
> First I'd like to say that I've been reading and reading on this issue and I
> thought I had a pretty good grasp on the subject, however, I still cannot
> eliminate the condition I am experiencing.
>
> The problem I'm seeing is when I first start up my application server,
> either Tomcat or Resin, and I run my application, which retrieves records to
> be displayed from the database, invalid data is displayed in some of the
> fields. Basically, the instance variables for the bean class are being
> trashed.
>
> I can only create this condition the first time after I stop and restart the
> application server. After the first occurrence, it does not seem to
> continue. This doesn't mean the condition doesn't exist, just that I can't
> seem to recreate it.
>
> I have set up a sample of the problem at http://www.zware.net/simpleDemo
>
> It is a very basic, very small sample amount of code that does what I
> outlined on the simple demo page. I've also provided the source code, so
> that anybody that might be willing to help me, could see how I am attempting
> to synchronize my code to avoid the condition I am seeing.
>
> In a nutshell, I create a bean for the user record. I then synchronize the
> bean and call a method to retrieve the data. Before exiting the synchronize
> block, I add the bean to the session object. I then exit the synchronize
> block and forward control to the jsp page to display the data.
>
> As I said, I can only cause the condition to occur in a very specific way,
> however, I'm inclined to believe that I'm doing something drastically wrong
> and I am afraid to continue developing anything until I completely
> understand how to avoid the multi-threading problem that I seem to be
> experiencing.
>
> I would appreciate any feedback that anybody could provide on what I've done
> wrong. Please don't slam me for code structure. This simple app was put
> together to be readable and to solicit some assistance with my
> use/understanding of how to synchronize an object.
>
> Synchronization seems pretty straight-forward, conceptually, however, I
> cannot resolve this issue. I've even gone so far as to use the implements
> SingleThreadModel on the SimpleCtl class, but this still does not resolve
> the condition.
>
> I'm wondering if it could be my JDBC driver? My backend database is MySql
> and I've tried a couple of version 3.x JDBC drivers, but again, I cannot
> resolve the problem.
>
> Any help is greatly appreciated.
>
> Regards,
>
> Brett
>
> Sample: http://www.zware.net/simpleDemo
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>




-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/
from the University of Hull Centre for Internet Computing
http://www.cic.hull.ac.uk/

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Checked by Hu-fw-scar

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to