How to handle multiple requests to the same servlet at one time?

Hi,
I am new to Servlets. I have doubt regarding ... Handling multiple requests to a servlet at a time.
If we send a single request to a servlet, as know that group of objects such as servlet, servletContext, servletConfig, request, response and etc are created in the server, And if 1000's of requests are sent to a same servlet at a time, and if server memory capacity is less, then 1000's of objects are created in a server which would be heavy burden to Server. How to handle the application and development in such situation?
Kind regards,
veerendra

Hi veerendra reddy ,
By default any web server can will have a thread pool to handle client req's.
In your point also heavy burden to server you are telling that depends on this.
we can configure this min & max size of this thread pool.
by default it will be 0-1000 for tomcat server.
I am not sure in which file this configuration will be.
But I hope in server.xml or some xml file consists this info.
If You what you can edit accordingly. to overcome your heavy burden to server.
Thanks & Regards
Nagendra

Similar Messages

  • How to handle multiple request in the servlet

    how to handle multiple request in the servlet...
    Example:
    java forum...
    i'm login in the java forum at this time 1000 members make login in this....how happended in servlet?
    if we use thread how to implement in servlet ?

    Serlets are already threaded. The application container instantiates the servlet, then uses this instance in a new thread for every use.
    This is the reason that you should use (almost) no instance variables in a Servlet, but rather that (almost) everything should be local to the method.

  • How to handle multiple exceptions by the same code?

    Hi, all:
    In my situation I want AException and BException handled by the same code, while CException and DException handled by another code. How can I write my try-catch code in a simple way? Of course I can do the following:
    public void TheMainFunction() {
        try {
        } catch (AException e) {
            Handle_AB();
        } catch (BException e) {
            Handle_AB();
        } catch (CException e) {
            Handle_CD();
        } catch (DException e) {
            Handle_CD();
    private void Handle_AB() {
    private void Handle_CD() {
    }But is there a simpler way?
    Thanks in advance.

    If you have one or two places in your code that need multiple exceptions, just do it with multiple catch statements. Unless you are trying to write the most compact Programming 101 homework program, inventing tricks to remove two lines of code is not good use of your time.
    If you have multiple catches all over your code it could be a code smell. You may have too much stuff happening inside one try statement. It becomes hard to know what method call throws one of those exceptions, and you end up handling an exception from some else piece of code than what you intended. E.g. you mention NumberFormatException -- only process one user input inside that try/catch so it is easy to see what error message is given if that particular input is gunk. The next step of processing goes inside its own try/catch.
    In my case, the ArrayIndexOutOfBoundsException and
    NumberFormatException should be handled by the same way.Why?
    I don't think I have ever seen an ArrayIndexOutOfBoundsException that didn't indicate a bug in the code. Instead of an AIOOBE perhaps there should be an if statement somewhere that prevents it, or the algorithm logic should prevent it automatically.

  • Concurrent multiple requests to the same servlet from same client

              We are using weblogic as our web and app. server. We are using the weblogic oracle pool for database connections. We have jsp and servlets in the second tier with EJB on the third tier.
              We have a problem like this. We have set the oracle pool max size to 40. Some of our database searches takes about 30 seconds. If a user submit a request for such a search, it takes about 30 seconds to respond to the client.
              In the mean time if the user submits the same request again and again (by clicking the URL link in the HTML page continuosly for 50 times), the servlet takes each request, creates new thread for each request, and each thread uses a connection. So our pool runs out of connections and further to that, we get 'resource unavailabe exception' or 'pool connection failed' etc.
              All the users hang. Some times it recover back, but most of the times the server crashes.
              We have not set any time out for pool connection waiting time. By default weblogic keeps the threads waiting for connection indefinitely.
              So, now if somebody want to crash our site, simply they can go and hit a database search link (which takes about 30 secs) 50 to 100 times, and out site will go down.
              What is the good solution for this. I think this is a common problem which many people should have solved. One way is to find and block the user who is hitting many times.
              Any better solutions pl.?
              regards
              sathish
              

              "Cameron Purdy" <[email protected]> wrote in message
              news:[email protected]...
              > There are other ways to do the processing besides JMS, but the main idea
              is
              > this: DO NOT DO IT ON A WL EXECUTE THREAD IN YOUR WEB SERVER -- those are
              > for your HTTP requests and you don't want to use them up. You can use RMI
              > and have your RMI object spin off a thread.
              Now we're going in circles. I've heard it repeatedly argued here that you
              don't
              ever want to do anything in the server that is not within a server execute
              thread.
              My "big process" needs to run on the server, since it manipulates EJB's
              etc.,
              in the same sense that JavaBeans launched from a JSP page run in the server.
              So, I just don't understand why now it's not ok to use execute threads, when
              I'm going to be initiating a thread of control in the server anyway.
              >
              > Here's the second issue: idempotency. Make sure you pre-assign an ID to
              > the task, and have that ID accompany the task as it runs, use that ID to
              > update a shared resource (perhaps db) to show the progress of the task,
              and
              > keep that ID in the shared resource afterwards so that the task is not
              > repeated unnecessarily (refresh) and so the user's request now shows that
              > the task is complete.
              >
              My solution associates an AsynchTask to object to a session scope JavaBean.
              So, for a given session, there can be only 1 task object, etc. Will this
              work?
              Thanks,
              Jason
              > --
              >
              > Cameron Purdy
              > [email protected]
              > http://www.tangosol.com
              > WebLogic Consulting Available
              >
              >
              > "Jason Rosenberg" <[email protected]> wrote in message
              > news:[email protected]...
              > > Cameron,
              > >
              > > A few questions....
              > >
              > > Is JMS the only way to "kick off the big process". Is there a way to
              > > launch another servlet, or god forbid, another thread, etc.?
              > >
              > > I'd rather not have to use JMS right now, due to time constraints
              > > (it's another thing to have to figure out...).
              > >
              > > Is it necessary to use javascript to redirect? Can't we just use
              > > a simple meta refresh tag, which causes the same jsp to be
              > > hit repeatedly, and which will keep resending the html with
              > > the meta-refresh until the "big process" has completed?
              > >
              > > Also, if we have a jsp which uses a bean with session scope,
              > > don't we then get built in "uid" tracking? The bean instantiated
              > > will necessarily be of the current session, it seems, as long as the
              > > user keeps the same browser window open (or does resending
              > > cause a new session to be started--I didn't think so....).
              > >
              > > Can you elaborate on how the completed process information can
              > > be shared back to the session, and then returned to the browser, etc.?
              > >
              > > Jason
              > >
              > >
              > >
              > >
              > >
              > > "Cameron Purdy" <[email protected]> wrote in message
              > > news:[email protected]...
              > > > This cut & paste feature is getting handy ..
              > > >
              > > > --
              > > >
              > > > 1) The work to be done is assigned a uid or something similar to
              > prevent
              > > it
              > > > from being done twice
              > > > 2) The user presses the button which passes the uid in a hidden field
              > > (for
              > > > example)
              > > > 3) The serlvet responds by kicking off the big process with jms and
              > sends
              > > > back a page that displays a "processing..." message and uses
              javascript
              > to
              > > > redirect (with a place to click just in case javascript is turned off)
              > > > 4) The url redirected to includes the uid to identify the process for
              > > which
              > > > the result is desired
              > > > 5) When the process is completed, the information is placed in some
              > known
              > > > location (e.g. HttpSession or database) and the pending request to
              find
              > > the
              > > > result can return the result
              > > >
              > > > --
              > > >
              > > > Cameron Purdy
              > > > [email protected]
              > > > http://www.tangosol.com
              > > > WebLogic Consulting Available
              > > >
              > > >
              > > > "sathish kumar" <[email protected]> wrote in message
              > > > news:[email protected]...
              > > > >
              > > > > We are using weblogic as our web and app. server. We are using the
              > > > weblogic oracle pool for database connections. We have jsp and
              servlets
              > in
              > > > the second tier with EJB on the third tier.
              > > > >
              > > > > We have a problem like this. We have set the oracle pool max size to
              > 40.
              > > > Some of our database searches takes about 30 seconds. If a user submit
              a
              > > > request for such a search, it takes about 30 seconds to respond to the
              > > > client.
              > > > > In the mean time if the user submits the same request again and
              again
              > > (by
              > > > clicking the URL link in the HTML page continuosly for 50 times), the
              > > > servlet takes each request, creates new thread for each request, and
              > each
              > > > thread uses a connection. So our pool runs out of connections and
              > further
              > > to
              > > > that, we get 'resource unavailabe exception' or 'pool connection
              failed'
              > > > etc.
              > > > > All the users hang. Some times it recover back, but most of the
              times
              > > the
              > > > server crashes.
              > > > > We have not set any time out for pool connection waiting time. By
              > > default
              > > > weblogic keeps the threads waiting for connection indefinitely.
              > > > > So, now if somebody want to crash our site, simply they can go and
              hit
              > a
              > > > database search link (which takes about 30 secs) 50 to 100 times, and
              > out
              > > > site will go down.
              > > > > What is the good solution for this. I think this is a common problem
              > > which
              > > > many people should have solved. One way is to find and block the user
              > who
              > > is
              > > > hitting many times.
              > > > > Any better solutions pl.?
              > > > > regards
              > > > > sathish
              > > >
              > > >
              > >
              > >
              >
              >
              

  • Does af:commandButton submit multiple requests at the same time?

    Hi experts,
    I have a question about af:commandButton behavior.
    I have two commandButtons in a page. They are button1 and button2.
    Button1 takes a few seconds to complete its request process.
    So when I click button1, I can click button2 although button1 request is still being processed.
    I checked how ADF faces handled this situation with servlet filter.
    And I saw that button2 request was always submitted after button1 request was completed.
    Due to this behavior, I would assume that commandButton is designed not to submit multiple requests at the same time and guarantees click order.
    However I couldn't found any documents specifying this feature of commandButton.
    If anyone knows it, could you share?
    I know ADF Faces has busyStateListener to prevent user inputs during request round trip.
    But I'd like to make it sure that I don't need to use busyStateListener if I just want to keep processing order.
    Regards,
    Atsushi

    Hi,
    Does anyone know the document specifying the behavior of af:commandButton in case I click two buttons in a page almost simultaneously?
    Any help will be much appreciated.
    Thanks in advance,
    Atsushi

  • How can I combine multiple deliveries of the same address to one shipment.

    Hello Friends,
    My client is sending multiple deliveires with multiple shipments to the same customer. His cost is increasingm therefore I am lookign to help him to combine all the deliveries to one shipment and one delivery.
    How can I combine multiple deliveries of the same address to one shipment.
    Please help me.
    Regards

    Of course, you can combine several deliveries into one shipment. You can set your own selection variant to select deliveries with the same ship-to party.
    You cannot combine several deliveries into one delivery. The combination of deliveres is possible only when creating deliveries in VL10*.
    Edited by: Harry Wu on Jun 21, 2010 4:30 AM

  • How can I print multiple copies of the same photo onto one sheet of paper?  Do I have to Duplicate the photo in iPhoto and then select them all?

    How can I print multiple copies of the same photo onto one sheet of paper?  Do I have to Duplicate the photo in iPhoto and then select them all?

    no - you simply have to select the option to print mucliples of a photo on a page
    select the photo and go to the file menu ==> print - select the printer, paper size and print size and click customize - in the tool bar click on the settings icon (the gear looking thingy) and select "multiple of the same photo per page" and the preview will reflect this option showing a full page of the selected size photos
    LN

  • How to have multiple images on the same screen? like in the movies where you see several actions at

    how to have multiple images on the same screen? like in the movies where you see several actions at the same time ....
    i don't find  a tutorial in adobe tv....
    thanks !!

    The short answer is that you'll put the source clip(s) for each inset on a different video track, all stacked up. Then use the Scale and Position effects (under "Motion" on the Effect Controls panel) to reduce their size and place them where you want.
    If the content of an inset will involve edited content (where you're cutting among various clips or just trimming out unwanted content from a single clip), then you'll probably find it easier to do all those edits in one sequence, then nest that sequence in the master sequence, where you apply the Scale and Positioning effects. That will save the step of applying the scale and position effects to each edited track item.

  • How to handle multiple selection in the Spark List control with checkbox as itemrenderer?

    Hi All,
    I am using checkbox as an ItemRenderer in spark list.
    I have a query.
    how to handle multiple selection in the Spark List control with checkbox as itemrenderer?
    how to retrieve the selected item label?
    Thank you in advance.

    Hi there, I'll tweak your code a little bit to something like this:
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                    layout="vertical">
        <mx:Script>
            <![CDATA[
                 import mx.events.ListEvent;
                 import mx.controls.CheckBox;
               [Bindable]
               private var mySelectedIndexes:ArrayCollection=new ArrayCollection();
                private function onChange(e:ListEvent):void
                   if(CheckBox(e.itemRenderer).selected){
                             mySelectedIndexes.addItem(e.rowIndex);
                   }else{
                                  mySelectedIndexes.removeItemAt(mySelectedIndexes.getItemIndex(e.rowIndex));     
                   chkList.selectedIndices=mySelectedIndexes.toArray();
            ]]>
        </mx:Script>
    <mx:ArrayCollection id="collection">
            <mx:Object label="Test A"/>
            <mx:Object label="Test B"/>
            <mx:Object label="Test C"/>
            <mx:Object label="Test D"/>
            <mx:Object label="Test E"/>
            <mx:Object label="Test F"/>
            <mx:Object label="Test G"/>
        </mx:ArrayCollection>
    <mx:List id="chkList" dataProvider="{collection}" itemRenderer="mx.controls.CheckBox"  itemClick="onChange(event);" allowMultipleSelection="true"/>
    </mx:Application>

  • How to handle an update of the same record from two different user  in JSP

    how to handle an update of the same record from two different user
    how do you handle an update of the same record from two different users in JSP... if one person updates the record from one drop downs should be updated as well.. is the possible.

    Usually, if two users try to update the same row at the same time, you want the first to commit to succeed, and when the second commits, they should fail with the error that the row was being concurrently updated. They you may want to show them the new row values and give them the opportunity to merge their values with the new row values...
    How can you achieve this? Google optimistic locking.

  • Multiple images of the same file on one page

    How do I create multiple images of the same file on one page? For example, I've got an image that I could fit 6 of on one page, and would like to print it that way instead of printing it on 6 individual pieces of paper.

    Are you attempting to do this in Adobe Workspaces? Or are you looking for software that will do it?
    If the former, you could insert the image into a Buzzword document six times. Not exactly elegant, but it might do the trick.

  • How to support multiple users at the same time?

    Hi all,
    I have a Labview software which controls a analyzer via GPIB connector. When user A is using the software, user B has to wait until A is done. But actually, the analyzer is not very busy, when user A is using the software.
    I want user A, B, C and D can use the software at the same time. just like we can open Multiple websites at the same time.
    How can I program the software, so that the software can be open multiple times? Do you have any example?
    Thanks a lot.
    Steven
    Solved!
    Go to Solution.

    Are all the users going to be measuring the exact same thing from the same instrument?
    It would be possible to write a separate instrument server application that would handle all the direct interactions with the instrument. When one of the users needed to access the instrument, they would gain access to it through this server.
    The big, Big, BIG caveat is that each interaction with the instrument would need to be atomic. In other words each access would need to configure the instrument, initiate the reading, report the results, and then reset the instrument back to some known default value.
    As Dennis said, not a trivial process, but probably do-able...
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • How to manage multiple sizes of the same image?

    I recently took up LightRoom for all the good things it does. One of the things I need to do, however, is to create and manage multiple sizes of the same image needed for different purposes. I always found this cumbersome. I totally expected that the LR library would offer a solution for this but I looked and I didn't see anything. Sure you can export and resize in the process but then you're on your own. Am I missing something? Isn't there a better way? What does Adobe have in mind for best practices and how do you handle this?

    I can't speak for 99jon, but when I need multiple sizes, I export at the desired sizes, and then make use of the exported photos (upload, e-mail, whatever) and then delete the exports. Thus, there's really no need for me to keep track of the photo at this specific size, knowing that if I ever need it again -- unlikely -- I can regenerate it with the export pre-set, so I put no effort (zero!) into keeping track of photos at different sizes.
    The idea of adding it back into the catalog doesn't get me excited, and I would advise against it. I don't need this, and I don't see the benefit of keeping this particular size export for the long-term. As I said, I can always recreate it — but maybe you have such a need to keep these exports long-term and recreating it at a later point in time doesn't meet your needs? Can you explain?
    By the way, you can't resize a virtual copy, so that won't work here. The only time you can resize is on export.

  • How biztalk handle multiple request at a time ?

    can TCP/IP adapter or biztalk handles multiple request at a time ?
    If yes,then how it process multiple request ? 
    Can TCP/IP send ports sends multiple request ?
    Prakash

    Yes.
    It processes multiple requests using THREADS. Each Connect starts off a thread that handles the receipt of the message, submission to BizTalk, wait for the response (matching two-way subscription) and then respond back to the client.
    TCP/IP Send ports handle multiple requests by creating fresh sockets (RPC High-end ports). As an example, in your browser you open multiple tabs and access different sites, each tab results in your browser opening a fresh socket connection for the request.
    Regards.

  • CLR trigger - handling multiple inserts at the same time

    Hi
    I've developed a CLR trigger which operates on inserts performed on a staging table. The trigger implements some business logic and then inserts or updates a record in a target table. Whether an insert or update is performed depends on whether
    a record with the same ID already exists in the target (i.e. a select * from target where ID = 123).
    This works fine in most scenarios, but occasionally I am getting duplicates in the target table and have noticed that this seems to occur when inserts on the staging table happen at exactly the same time (i.e. multiple inserts for the same ID at
    the same time). In this situation duplicates are created in the target table because at the time of the inserts, no record with that ID exists in the target table (i.e. the select returns no records), therefore a new record is created for each.
    Is there a known way to deal with this scenario? For example, would locking the target table on insert result in the subsequent selects against the target table waiting until the target table had been updated, therefore the select would return a record
    for the given ID.
    I didn't really want to lock the whole target table on insert, because there are potentially other users reading that table (selects) and these would also have to wait for the insert to complete.
    I'd appreciate any thoughts on how to deal with this and avoid duplicates in the target table. I'm unable to change the way the data is coming in to the staging table, so my trigger code must deal with the above scenario.
    Thanks in advance.
    John

    First if you do not want any duplicate values in a column (or combination of columns) you should add a constraint to ensure this is never possible. A
    unique index
    like this should do this trick.
    CREATE UNIQUE NONCLUSTERED INDEX [IX_yourIndexName] ON [dbo].[YourTableName]
    [yourColumn1] ASC,
    -- add more columns that make the unique combination that you don't want repeated
    You can then add a try/catch block in your trigger code, if you get an exception based on this index then the record was created by another executing instance of this trigger and in that case you should do an update (or not, not sure what the rest of your
    logic is) in your catch block. This is the easiest solution and does not involve table locks. The only drawback is the first one to commit the insert will win and you have no guarantee which process or data set that will be. Also i have no idea how big the
    table is, how frequently changes are made, and what the data type is so you should
    keep this in mind when creating your index so you don't run into unexpected high index fragmentation which can lead to performance problems when executing updates and inserts.
    You could also create a
    named transaction with scope serializable around your insert/update block and execute your reads using a
    NOLOCK hint
    which should allow them to retrieve uncommitted writes and not create a long wait. The downside is is that the data might not be 100% accurate depending on if a transaction fails or not if there happens to be an update at the same time as a select but maybe
    this is not a big deal to the calling code.
    -Igor

Maybe you are looking for

  • R/3 SOURCE SYSTEM in BW

    Hi,    RSA1>Source System> WRD(R/3) Context menu check.... message--SOurce system is inactive    when i selected activate on context ment it is displaying 'Timed OUT' message How shall i proceed Thanks

  • Satellite A40-271 - Where can I find drivers?

    Helllo everybody, I have a Satellite A40-271, model number: PSA40E-09XD2-SP, and I don't find drives/support for it on toshiba web. Is there any similar model to download drivers? I want to know how I can enable WPA on my Toshiba Wireless LAN Mini PC

  • Payments to customers

    One of our customers demands some changes within the Business One. The support in Ireland advised us to post these requirements in this Forum. It's not possible to give as a customer declared BP a payment. This is sometimes necessary, if a customer h

  • Motion 3...3D models & file formats !

    The 3D enhancement makes Motion and is far more user friendly than After Effects, in my opinion. But & there's always a but...can we bring true 3D models into motion like the ones produced in Lightwave, Cinema 4D etc. If the answer is yes what 3D fil

  • Retrieving technical settings for existing structure

    Hi! how to retrieve technical settings for existing structure? Is it somewhere in SE11? Will reward, Mindaugas.