To implement these functions, I have several files (which may have problem), they are: topics.jsp, details.jsp, newTopic.jsp, followTopic.jsp, upload.jsp. Also, I use forumID, topicID, and postID to uniquely identify a post (like every forum)
All these functions work perfectly in normal situations. But occasionally, when there are about 20 active people (registered users) on my website (about more than 100 visitors at that moment), serval of them are trying to post. The following problem may come (not always):
1. When they are trying to view the post details (called details.jsp file), they get the content of another post. You can see from URL address in IE, the forumID, topicID are correct, but the details are from another seems random one. And normally, in one page, I set it to show 10 posts of one topic. But if such thing happened, it can only show one post sometimes. And sometimes, the first several posts are correct, but the last several post are from other topic with different forumID and topicIDs. But if you refresh the page, most probably, you will get the correct content.
2. When people try to reply (follow) a topic, the post is appended to another topic, which means the same. The forumID and the topicID was confused the system.
3. When people were trying to upload a file, I firstly put the file in a temporary directory under somedirectory/userID/ and then move it to the destination. But sometimes, the attachment cannot be found when the system was trying to move it because the file had been put to a directory like:
And I know that the user of userID and the user of anotheruserID were both active at that moment.
I am coding all these function in JSP and mysql, using Apache and tomcat.
All the 3 problems all look similar, which may be due to the synchronization problem or, anyway, because the system confused of processing the request from diffrent users.
Anybody please kindly give me some idea? Thanks very very much!
Are you storing any data in instance variables of a servlet? Are you using the <!% %> construct in JSPs to store variables?
P.S. Could you do us a favor and modify your display name to mixed case rather than uppercase. It'll be easier on all our eyes. Thanks.
int userid = umUtil.getUserIDByName(username, host, dbname, user, pass);
and the userid is sometimes messed up as well.
By the way, the umUtil is more like a static class, although it is not. In the class of umUtil, the method of getUserIDByName is just a connection to the database and then select the ID, and then close the connection and return the userid.
And I define this bean on the top of this file like this:
<jsp:useBean id="umUtil" class="um.UMUtil" scope="session" />
Thanks very much!
Originally posted by Philip SHOU:
Yes, on top of these files, I have something like:
int forumid, subjectid, postid;
so what's the problem of using this way?
I am new here. I don't know how to modify my display name. Thanks for your reply and I am sorry about my display name.
Variables declared in the outside of your service method (For JSPs, that means within the <%! ...%> blocks) are common to all requests. The simplest way to fix this is to move the declarations out of that block.