• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but still the same even after implementing " isThreadSafe="false" " is theis any other alternative to this. kindly help
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
I yam what I yam and that's all that I yam - the great philosopher Popeye. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic