Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

JSP service method synchronization

 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sun�s ePractive exam includes the following question:

Your organization has developed a new J2EE Invoicing system, and during load testing the system runs slow, but CPU and memory utilization remain low. To save time they embedded all the business logic into the JSPs as scriptlets.

What could be a cause of the problem?

A. You need to scale your application horizontally
B. You need to scale your application vertically
C. Servlet instances are getting locked for every request
D. You are dropping database connections
E. Your load balancer needs to be re-polarized

The answer they give is as follows (Reference - Servlet 2.4 spec)

Option C is correct because the default behavior for JSPs is for the service method to be synchronized in the resulting servlet

I�ve always been of the opinion that the default model for Servlets, including Servlets generated from JSPs, is a multithreaded one. This is borne out by the Servlet and JSP specs. The JSP spec has the following to say about the isThreadSafe page attribute:

Note: The Servlet 2.4 specification deprecates SingleThreadModel, which is the most common mechanism for JSP containers to implement isThreadSafe. Page authors are advised against using isThreadSafe, as the generated Servlet may contain deprecated code.

Indicates the level of thread safety implemented in the page. If false then the JSP container shall dispatch multiple outstanding client requests, one at a time, in the order they were received, to the page implementation for processing. If true then the JSP container may choose to dispatch multiple outstanding client requests to the page simultaneously.

Page authors using true must ensure that they properly synchronize access to the shared state of the page.

Default is true.

Note that even if the isThreadSafe attribute is false the JSP page author must ensure that accesses to any shared objects are properly synchronized. The objects may be shared in either the ServletContext or the HttpSession.

Am I missing something obvious here?
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you are correct. I'd be interested to know the answer to.
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i answer 'C' because the others are surely incorrect!
 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think 'C' is for surely incorrect since there is only one Servlet instance it runs under threads
 
J J Wright
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm going to contact Sun directly regarding this one. I'll update the thread accordingly when, or should that be 'if', I get any feedback.
 
Alas, poor Yorick, he knew this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic