14. Explain JSP/Servle threading model.

Every Servlet contains a doGet or doPost method.
When we deploy a servlet the init method of the servlet is called. And after it has been deployed on each request of the servlet a separate thread is created to process the doGet/doPost method of the servlet.
So all the instance variables of the servlet are not thread safe.
We can override this behaviour by implementing SingleThreadedModel in the servlet which tells the servlet container to create a new Servlet instance for each client’s request instead of using a single Servlet Instance.

But single threaded model is deprecated now in Servlet 2.4 API. API doc says ” Note that SingleThreadModel does not solve all thread safety issues. For example, session attributes and static variables can still be accessed by multiple requests on multiple threads at the same time, even when SingleThreadModel servlets are used. It is recommended that a developer take other means to resolve those issues instead of implementing this interface, such as avoiding the usage of an instance variable or synchronizing the block of the code accessing those resources. ”

this might be the reason why it has been deprecated.

10 Responses

  1. I think this answer is fine.

    Regards,
    Astha

  2. Thanks for sharing this information. Really is pack with new knowledge. Keep them coming.

  3. I got such a useful and cleaned information from this blog. thanks and keep updating.

  4. Hello,
    I’m new! Any news?

    ——————
    diet

  5. How to run thread process in jsp?

  6. i was looking all over the employment after leopard bittorrents i institute http://www.osxtorrents.com and it’s awesome.they no more than entertain leopard osx torrents so you remember your not prospering to realize any other torrents.

  7. 100 percent free arab online dating sites
    free online christian dating
    top or best 10 online dating sites
    married discreet dating service
    advice on dating and relationships
    honolulu 100% free friendship and dating singles websites
    100 percent free sex online dating
    interracial dating in ohio
    free local dating sites online
    free online dating personal
    greer sc senior dating
    free 100% online horny married women dating sites
    new york speed dating
    free dating services in south carolina
    speed dating hawkes bay
    100 free dating online woman and man in love
    totally free online dating
    free senior dating services
    free over 60s dating sites uk only
    free gay dating sites
    100 % free online gay dating sites
    free asian dating service
    dating sites in the uk
    asian speed dating nyc
    free dating web sites
    hot sim dating games
    melbourne asian dating
    advice cell couple dating phone relationship
    adult personals online dating
    dating tips for teenage boys
    free local adult personals single dating
    100 free dating sites in usa and canada
    mj interracial dating

    collier
    wei
    wolanin

    surly
    steganographic
    etorrem

    google you in help)))

  8. I’ve just stubled upon this site amatchprofiles.com, should I buy access to it?.

    Jacob

  9. Thanks for putting in all the effort to create this entry

  10. I’ve just stubled upon this site http://www.xxxbookprofiles.com, should I join it?.

    Elizabeth

Leave a reply to bruisymmess Cancel reply