ServletConfig is used by only single servlet to get configuration information from web.xml whereas ServletContext is used by multiple objects to get configuration information from xml files. | 0 |
By: [email protected] On: Mon Apr 07 11:08:50 IST 2014 0 20 0 | 20 |
Are You Satisfied :2Yes3No |
ServletConfig 1.ServletConfig available in javax.servlet.*; package 2.ServletConfig object is one per servlet class 3.destroyed once the servlet execution is completed. 4.We should give request explicitly, in order to create ServletConfig object for the first time 5.Object of ServletConfig will be created during initialization process of the servlet 6.This Config object is public to a particular servlet only ServletContext 1.ServletContext available in javax.servlet.*; package 2.ServletContext object is global to entire web application 3.Object of ServletContext will be created at the time of web application deployment 4.Scope: As long as web application is executing, ServletContext object will be available, and 5.it will be destroyed once the application is removed from the server. 6.ServletContext object will be available even before giving the first request | 0 |
By: [email protected] On: Mon Apr 07 13:33:33 IST 2014 0 392 0 | 392 |
Are You Satisfied :2Yes1No |
The servletconfig object refers to the single servlet whereas servletcontext object refers to the whole web application. | 0 |
By: [email protected] On: Sun Apr 03 12:17:45 IST 2016 0 0 0 | 0 |
Are You Satisfied :0Yes0No |
ServletConfig: Signature: public interface ServletConfig ServletConfig is implemented by the servlet container to initialize a single servlet using init(). That is, you can pass initialization parameters to the servlet using the web.xml deployment descriptor. For understanding, this is similar to a constructor in a java class. Example code: <servlet> <servlet-name>ServletConfigTest</servlet-name> <servlet-class>com.javapapers.ServletConfigTest</servlet-class> <init-param> <param-name>topic</param-name> <param-value>Difference between ServletConfig and ServletContext</param-value> </init-param> </servlet> ServletContext: Signature: public interface ServletContext ServletContext is implemented by the servlet container for all servlet to communicate with its servlet container, for example, to get the MIME type of a file, to get dispatch requests, or to write to a log file. That is to get detail about its execution environment. It is applicable only within a single Java Virtual Machine. If a web applicationa is distributed between multiple JVM this will not work. For understanding, this is like a application global variable mechanism for a single web application deployed in only one JVM. The ServletContext object is contained within the ServletConfig object. That is, the ServletContext can be accessed using the ServletConfig object within a servlet. You can specify param-value pairs for ServletContext object in <context-param> tags in web.xml file. Example code: <context-param> <param-name>globalVariable</param-name> <param-value>javapapers.com</param-value> </context-param> | 0 |
By: [email protected] On: Thu Jun 30 12:27:35 IST 2016 0 0 0 | 0 |
Are You Satisfied :0Yes0No |