0

As I am new to Servlets i want to know what is difference between ServletContext and ServletConfig objects.

I want to know that in servlets lifecycle which object was firstly created on container startup.

Pranjal Bikash Das
  • 1,092
  • 9
  • 27
nasir
  • 107
  • 2
  • 14
  • 2
    ServletContext represents the whole webapp. ServletConfig represents the configuration of one servlet in this webapp. The javadoc explains that. Have you read it? Whether the container creates one before the other is meaningless. You shouldn't care about that. Why do you care? – JB Nizet Nov 05 '17 at 08:52
  • Just wanted to understand the flow, as servletConfig scope is within the servlet and servletContext's scope is at application level which will be created when our application deployement time, but servlet will be configured thru init() method only which is accepting servletconfig as parameter so got confused when which object is being created and thank u for your answer – nasir Nov 05 '17 at 09:11
  • I don't understand why you think that it would be possible to configure a servlet without having a servlet context. – BalusC Nov 05 '17 at 14:22
  • Sir, exactly where i got stuck while container startup can i say that firstly Servletconfig object is being created for initializing the servlet or servletContext object is being created because am not able to find an accurate answer to this@BalusC – nasir Nov 07 '17 at 09:33

0 Answers0