Difference Betwixt Servletconfig In Addition To Servletcontext Inwards Jsp Servlet J2ee
Difference betwixt ServletConfig and ServletContext
ServletContext and ServletConfig these ii are of import interface of Servlet API which is used yesteryear Java J2EE programmer during spider web application development. Correct agreement of What is ServletContext and ServletConfig is real of import for whatever J2EE application developer. Apart from that Difference betwixt ServletContext and ServletConfig are a popular Servlet JSP interview questions as well as to a greater extent than oftentimes than non asked on both fresher as well as experienced Java programmer during J2EE interviews. Both ServletContext as well as ServletConfig are basically configuration objects which are used yesteryear servlet container to initialize diverse parameter of spider web application. But they accept around deviation inward damage of scope as well as availability hence outset nosotros come across what is ServletContext as well as ServletConfig objects are as well as and hence nosotros volition come across difference betwixt ServletConfig as well as ServletContext inward Java J2EE.
What is ServletConfig inward JSP Servlet
ServletConfig in an interface inward Servlet API as well as ServletConfig object represents or used to initialize unmarried servlet inward web application yesteryear servlet container. Inside deployment descriptor known every bit web.xml, we define Servlet initialization parameter related to that servlet within <init-param></init-param> tag. its a ready of get upward /value pair. Following is signature of ServletConfig interface :
public interface ServletConfig
By using ServletConfig as well as combination of init-param yous tin configure whatever Servlet inward J2EE environment.
What is ServletContext inward Servlet JSP
ServletContext is fifty-fifty to a greater extent than of import than ServletConfig as well as its ane per spider web application, besides known every bit Context. This object is mutual for all the servlet as well as they purpose this object to communicate amongst the servlet container to larn the exceptional of whole spider web application or execution environs of import affair to recall is, it represents a spider web application inward unmarried JVM.
Signature: public interface ServletContext
By using ServletContext object yous tin percentage objects to whatever Servlet or JSP inward whole spider web application. See how to larn ServletContext inward Servlet JSP as well as Struts to detect out unlike ways of getting ServletContext inward J2EE application.
Difference betwixt ServletContext vs ServletConfig
Now let’s come across deviation betwixt ServletContext and ServletConfig in Servlets JSP inward tabular format
Servlet Config | Servlet Context |
Servlet config object stand upward for unmarried servlet | It stand upward for whole spider web application running on exceptional JVM as well as mutual for all the servlet |
Its similar local parameter associated amongst exceptional servlet | Its similar global parameter associated amongst whole application |
It’s a get upward value distich defined within the servlet department of web.xml file hence it has servlet broad orbit | ServletContext has application broad orbit hence define exterior of servlet tag inward web.xml file. |
getServletConfig() method is used to larn the config object | getServletContext() method is used to larn the context object. |
for illustration shopping cart of a user is a specific to exceptional user hence hither nosotros tin purpose servlet config | To larn the MIME type of a file or application session related information is stored using servlet context object. |
That’s all on What is ServletContext, What is ServletConfig as well as What are differences betwixt ServletContext as well as ServletConfig inward J2EE environment. Most of import deviation to recall is that ServletContext is per spider web application piece ServletConfig is per servlet basis. ServletContext is besides refer every bit application orbit inward JSP
Further Learning
Difference betwixt PATH as well as Classpath inward Java
0 Response to "Difference Betwixt Servletconfig In Addition To Servletcontext Inwards Jsp Servlet J2ee"
Post a Comment