Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how many HttpServletRequest objects are there on deploy time  RSS feed

 
eugene malcolumn
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
at deploy time if there are 100 servlets in an application will 100 request response objects will be created by container??
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The number of HttpServletRequest and HttpServletResponse instances is not related to the number of servlets. Depending on the size of your request pool (which you can often configure in a container specific way), you can have several hundreds of concurrent request, and each request needs its own HttpServletRequest and HttpServletResponse.
 
eugene malcolumn
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
before the first request is made are there any request objects???if not then what is Interface ServletRequestListener?
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
eugene malcolumn wrote:before the first request is made are there any request objects???

That probably depends on the container. Some may create a pool beforehand, and some may create objects only when they are needed. The thing is, you shouldn't have to care about that, just let the container manage the requests and responses. Just make sure to not use them after the request has finished, or you may get strange results.

if not then what is Interface ServletRequestListener?

It's a listener that you can use so the container can let you know when a request has been created, and when it is destroyed. You could use this to pre-fill a set of request attributes, make sure a session exists, etc.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!