• Post Reply Bookmark Topic Watch Topic
  • New Topic

servletconfig object

 
siddharth das
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a doubt whether a servletconfig object for a particular servlet is different for each request or same for each request.
Thanks,
Siddharth
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A ServletConfig instance is not passed to each request, so could you explain what you are asking?
 
siddharth das
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A servlet is once instanciated when the first request came i.e servletconfig object is same for all the subsequent requests.
Am I right or wrong?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You didn't answer my question. How are you obtaining a ServletConfig instance on each request?
 
siddharth das
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think we cannot get the reference of servletconfig object from request object.The servletconfig object is instaciated by the container and pass to the init() when first request come..
Thanks
 
siddharth das
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so the data which present in servletcontext object can be sharable to multiple request.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
siddharth das wrote:I think we cannot get the reference of servletconfig object from request object.

So, if you don't get a reference to a ServletConfig instance on every request, does your question still make sense?

The servletconfig object is instaciated by the container and pass to the init() when first request come..

Sort of. The servlet is guaranteed to be initialized before the the service method is called for the first time, but the container doesn't necessarily have to wait until a request comes in.
 
siddharth das
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
I have one more question.
Does the data present in servletContext object share through multiple requests?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
siddharth das wrote:Does the data present in servletContext object share through multiple requests?

There is only one ServletContext instance per web application.
 
siddharth das
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya, that I know.
If we store some data in servletcontext object in first request.Will that data can be accessed in 2nd request.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
siddharth das wrote:Ya, that I know.
If we store some data in servletcontext object in first request.Will that data can be accessed in 2nd request.

Your first statement answers the second.

Besides, seems easy enough to try it out. What happens when you test it?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!