Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can't 2 users access the same jsp page at time

 
Srinath R
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a jsp page which is written for retreving the data from the data base now this program works very fine when one user usses it but when more users use it giving the same criteria for retrevial then it shows no data found exception. my database is in sql server does it got to do anything with it. kindly tell me what to do.
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Each request for a jsp or servlet is served by separate threads. Where do you have the code? In jsp or servlet ? Do you use instance vars/static vars ? Because they are shared by other requests also (unless you implement the 'SingleThreadModel' Servlet).
Please post the code snippet so that we understand more clearly.
regds
maha anna
 
Srinath R
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the code is written in jsp and i also have instance variables i dont think i will be able to past the code its almost 600 lines and each bit of it contrubits to the output can u let me know how would i b able to implement singlethreadmodel.
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am in middle of another work. Off of my mind this comes up. If I am not wrong, there is a 'isThreadSafe=false' attribure in <@ page ...> directive . please check the jsp tag reference and make isThreadsafe=false and give it a try. It may make the performance slow though.
regds
maha anna
 
Srinath R
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but still the same even after implementing " isThreadSafe="false" " is theis any other alternative to this. kindly help
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you create the database connection(s), statement(s) and resultset(s) in a <%! ... %> block?
If so, do this elsewhere. Everything in such a block is static (and can thus be modified by only one instance at a time.
Another possibility is that your database will not accept more connections than the number created by a single request.
 
Srinath R
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%!
DBHandlerdbHandle;
ResultSetrs;
StringsearchString, searchType;
StringreportType, sqlString;
VectorindexWords, srchWords;
VectorfileNames; //field to store the file names.
HashtablestoreReports, storeDates;
Connectionconn;
PreparedStatementpstmt;
Stringroot, queryString;
booleanYesNo;
intsize,temp1=0;
intj,sri,my1;
int temp2=10;
intindexno = 0;
String getstring1,getstring2,getstring4;
java.util.Date getdate1;
String color,textcolor;
int mydisplay1;
//clossing the decleration
%>
this is waht i have between my <%! .. %> tags i dont think any where i have created any connection or statement or resultset only i have declared them here kindly let me know what could b the remedy for the second option u have given.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although you don't create the connection in the class body, you do store it there, which can cause confusion between multiple threads. Try moving all your database-related variables into the request-handler part of your JSP. For example
 
Srinath R
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i have changed the code as u have suggested, now sometimes it is showing some internal server error 500 and i am unable to decode where the error is present, sometimes it is showing the result of some other request on the whole the prg has become unconistent , suggest me what to do now
expecting a responce
all this is only when 2 users access the same prg at the same time
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic