Your problem shouldn't occur unless you use instance variables in your
servlet. A quick fix would be put

synchronized (session) {

}

Block outside your code.

-----Original Message-----
From: Satish Plakote [mailto:[EMAIL PROTECTED] 
Sent: November 22, 2004 10:10 PM
To: Tomcat Users List
Subject: RE: problem with simultaneous query submissions


here is my dopost method


 // Code starts here

       public void doPost(HttpServletRequest req,HttpServletResponse res)
throws IOException, ServletException
    {
        System.out.println("Inside doPost");

        String  strQueryFlag =req.getParameter("new");

        if(Integer.parseInt(strQueryFlag.toString())==NEW_QUERY)
        {
           System.out.println("New Search ..."+strQueryString);
           Query query = null;
           session.removeAttribute("BookObjects");
           ArrayList arLstBookDetails = new ArrayList(10000);

           try {
                 // Code to get data from Database or file
             } catch (Exception e) {
                    e.printStackTrace();
              }
           try{
               searchlog.println("--Creating  objects--"+"
"+session.getId()+" "+queryString);
               StringBuffer strDesc      = null;
               StringBuffer strBookID    = null;
               StringBuffer strItemName  = null;
               StringBuffer strItemCode  = null;
               StringBuffer strPrice     = null;
               StringBuffer strPageID    = null;
               StringBuffer strBookName  = null;
               StringBuffer strUrl       = null;
               StringBuffer strImage     = null;
               for (// access data one by one from structure )
                 {
                    try{
                         // for each element
                        strDesc      = // get the data and store it
                        strBookID    = // get the data and store it
                        strItemName  = // get the data and store it
                        strItemCode  = // get the data and store it
                        strPrice     = // get the data and store it
                        strPageID    = // get the data and store it
                        strBookName  = // get the data and store it
                        strUrl       = // get the data and store it
                        strImage     = // get the data and store it
                        strPageID    = // get the data and store it

 
if(hBookFromLucene.containsKey(strBookID.toString()))
                        {
                            BookDetails
BKDetails=(BookDetails)hBookFromLucene.get(strBookID.toString());
 
BKDetails.addPageDetails(strPageID,strPrice,strItemName,strDesc,strItemCode,
strImage,strUrl);
                        }
                        else
                        {
                            BookDetails BKDetails= new
BookDetails(strBookName,strBookID);
 
BKDetails.addPageDetails(strPageID,strPrice,strItemName,strDesc,strItemCode,
strImage,strUrl);
 
hBookFromLucene.put(strBookID.toString(),BKDetails);
                                   // adding objects to arraylist
                           arLstBookDetails.add(BKDetails);
                         }
                          // one  more structure to store all objects

m_objallBookDetails.addBook(strBookName,strBookID,strPageID,strPrice,strItem
Name,strDesc,strItemCode,strImage,strUrl);
                        }catch(Exception e)
                        {
                            System.out.print("SearchDataBean:
createBookObjects 1 "+e.getMessage());
                            e.printStackTrace();
                        }
                    } // end of for
                    strBookName  =  strBookID  =  strPageID = strPrice =
strItemName = strDesc = strImage = strUrl = null;
                }

                searchlog.println("Putting data for session
"+session.getId()+" "+arLstBookDetails.size());

                    // These two        structures together can store 100000
data individually in session.
                session.setAttribute("BookObjects",arLstBookDetails);
                    session.setAttribute("AllBookObj",m_objallBookDetails);
                searchlog.println(" --- Completed---
"+arLstBookDetails.size());

        }catch(Exception e)
        {
            System.out.println("SeachDataBean:getResultData: ");
            e.printStackTrace();
        }
    }

 // Code ends here

The reason i am storing the data is session is the the user is given a lot
of filtering options and i don't want to go back to my data source retrieve
data and show.. all the filtering has to be done from objects in memory so
thatit takes the minimum possible time.

is the huge amount of  data that i am storing that causes the problem ???

rgds
satish

-----Original Message-----
From: QM [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 23, 2004 7:36 AM
To: Tomcat Users List
Subject: Re: problem with simultaneous query submissions



Please post a *new* message when writing to the list.  Replying to an old
(unrelated) message confuses thread-aware mailers, which makes your question
harder to find (and thus answer).


On Tue, Nov 23, 2004 at 07:13:21AM +0530, Satish Plakote wrote:

: I have written a servlet that takes the input from user , queries the
database and creates objects of the information that is
: recieved. These objects (approximatley 100000 )  are stored in the
ArrayList which put in the session.using
session.putAttribute()

You're storing an ArrayList of 100,000 elements in the user session? That's
bound to cause problems...  For one, think of the amount of data being
pulled back from the database, not to mention the memory used by these
objects.

You'd do well to limit the scope of the DB result list, even if that's not
(directly) related to the problem.


: While testing i noticed that if i open two browsers,with two different
session ID, if submitted simultaneoulsy , one browser stops
: execution. i.e one instance of the servlet stops.. where as the other one
proceeds fine..This happens for n broswers..

Do you open two different browsers, or two windows of the same browser?



: There is no problem with database connection as i have tested it.

Exactly how have you tested this?



: My servlet is only extending the HttpServlet.And my arraylist is not a
class instance variable.each instance of the servlet is
: expected to keep its own copy..

Post the code, and someone here may be able to take a look at it.

-QM

--

software  -- http://www.brandxdev.net
tech news -- http://www.RoarNetworX.com


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


!DSPAM:41a2aa30170328693721181!

Reply via email to