what is the use of servlet context

what is the use of servlet context

what is the use of servlet context

View Answers

May 7, 2012 at 3:20 PM

ServletContext is a interface which helps us to communicate with the servlet container. There is only one ServletContext for the entire web application and the components of the web application can share it.

It gives information about the environment. It represents a Servlet's view of the Web Application.Using this interface servlet can access raw input streams to Web Application resources, virtual directory translation, a common mechanism for logging information, and an application scope for binding objects.

The Mapping of the Context init parameters in web.xml as:

<servlet>
    <servlet-name>Mapping</servlet-name>
    <servlet-class>ContextMapping</servlet-class>
</servlet>

<context-param>
    <param-name>Email</param-name>
    <param-value>[email protected]</param-value>
</context-param>

We can access the Init parameter in the servlet using ServletContext :

ServletContext context = getServletContext();
pw.println(context.getInitParameter("Email");









Related Tutorials/Questions & Answers:
Servlet Context
Servlet Context  Defined Servlet Context
Use Log in Servlet Context
Use Log in Servlet Context       This section illustrates you how to use log in Servlet Context. We are providing you an example. In the given example, an object of Servlet Context is defined
Advertisements
What is Application Context?
What is Application Context?  Hello, What is Application Context? Thanks
what the use of taglib - JSP-Servlet
what the use of taglib  what is the use of taglib where we exactly use it?  Hi Friend, It is used to create custom tag in jsp. For more information, visit the following link: http://www.roseindia.net/jsp
Context attributes in Servlet
Context attributes in Servlet       In this section you will study about the use of  Context Attributes in Servlet. All Servlets belong to one servlet context. A Servlet
Context Log Example Using Servlet
Context Log Example Using Servlet       This example illustrates about how to use of Context Log in servlet. Context Log is used to write specified message
What are difference between Bean Factory and Application Context ?
What are difference between Bean Factory and Application Context ?  Hi, What are difference between Bean Factory and Application Context
Servlet Context
Servlet Context In this section we will read about the SevletContext...-param></context-param> tags. So, changing of information what you would... the Servlet we can specify the value within the <context-param> <
Spring Context Loader Servlet
Spring Context Loader Servlet   ... (org.springframework.web.context.ContextLoaderServlet)ADS_TO_REPLACE_1 Context Loader Servlet... already enforce this behavior. If you use such a container, this servlet can
What is wrong with my servlet?
What is wrong with my servlet?  I'd like to know which part of the code is wrong. My code is: print("code sample"); import java.util.*; import java.io.IOException; import java.io.PrintWriter; import
Servlet: What is it
What is Servlet? The Servlet is a class that is written in Java programming.... What does Servlet do? A servlet is a class, which responds to HTTP request.... It interacts with clients via request-response programming model. Servlet
Servlet Tutorial
. This section describes you What is Servlet, Use of Servlet, Servlet container, Servlet API, Servlet life cycle, versions of Servlet, Servlet Container Servers What... on Web Server whereas Applet runs on Web Browser. Use of Servlet Servlet
Servlet Context
Servlet Context      ... with the servlet container. There is only one ServletContext for the entire web... that each servlet will have its own ServletConfig. The ServetContext is created
What is the difference between JSF, Servlet and JSP?
What is the difference between JSF, Servlet and JSP?  What is the difference between JSF, Servlet and JSP
context
context  what is context in general in java ?   An association between a name and an object is called a binding, and a set of such bindings is called a context
ModuleNotFoundError: No module named 'use-context'
ModuleNotFoundError: No module named 'use-context'  Hi, My Python... 'use-context' How to remove the ModuleNotFoundError: No module named 'use-context' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'use-context'
ModuleNotFoundError: No module named 'use-context'  Hi, My Python... 'use-context' How to remove the ModuleNotFoundError: No module named 'use-context' error? Thanks   Hi, In your python environment
Java : What is servlet?
Java : What is servlet? This section define the concept of java servlet. Servlet : Servlets are small java programs run on web server. You can say..., which is handled by the servlet.ADS_TO_REPLACE_1 We use javax.servlet
What values initialized inside init() in servlet - Java Interview Questions
What values initialized inside init() in servlet  What will happen inside init() in servlet. my interviewer asked servlet lifecycle. i said "once servlet is loaded in to memory init() will be called which performs servlet
servlet question on web application
What is servlet context?   What is servlet Context? Given me an example
What is Hibernate and what is its use?
What is Hibernate and what is its use?  Hi, What is Hibernate and what is its use? Thanks   Hi, Here is the details you asked? What...? What is Hibernate in Java? What is use of Hibernate? Hibernate is famous and one
What is Hibernate and what is its use?
What is Hibernate and what is its use?  Hi, What is Hibernate and what is its use? Thanks   Hi, Here is the details you asked? What...? What is Hibernate in Java? What is use of Hibernate? Hibernate is famous and one
What is Servlet in Java?
applications that can run on any servlet enabled web server. Servlets use of Java... to create sophisticated server side extensions. Developers use Servlet to add.... Servlet receives a request from user and generates a response and displays it back
How to use Servlet and Ajax?
How to use Servlet and Ajax?  How to use Servlet and Ajax
Servlet
Servlet  What is Servlet
Why <servlet-name> use in web.xml - JSP-Servlet
Why <servlet-name> use in web.xml  WHY DO WE USE THE <SERVLET-NAME>TAG IN WEB.XML APPLCATION   WHY DO WE USE THE <SERVLET-NAME>TAG IN WEB.XML APPLCATION AND HOW A simple program of using <servlet
What is the difference between JSP expression language and scriptlets? - JSP-Servlet
What is the difference between JSP expression language and scriptlets?  Hi, I just want to ask what is the difference between JSP Expression... or methods to use later in the file, write expressions valid in the page scripting
Servlet Interview Questions - Page 2
if you want your servlet to be initialized when context is loaded, you have to use a concept called pre-initialization of Servlet. In case of Pre-initialization, the servlet is loaded when context is loaded. You can specify <load
Pre-initialization of Servlet
to be initialized when context is loaded, you have to use a concept called pre...Pre-initialization of Servlet   What is meant by Pre-initialization of Servlet?   When servlet container is loaded, all the servlets
What is the use of DESC in SQL?
What is the use of DESC in SQL?  What is the use of DESC in SQL
What is the use of friend function?
What is the use of friend function?  What is the use of friend function
What is use of a abstract variable?
What is use of a abstract variable?   Hi, What is use of a abstract variable? thanks
What is use of a abstract variable?
What is use of a abstract variable?   Hi, What is use of a abstract variable? thanks
What is the use of Bluetooth technology
What is the use of Bluetooth technology  What is the use of Bluetooth technology?   Bluetooth technology is used for Wireless communication between equipment's
What is the use of Java?
What is the use of Java?  Hi, What is the use of Java programming Language? How Java is useful for creating applications? Thanks   Java.... You can check more details at What is the use of java?. Thanks
what is use of push in javascript
what is use of push in javascript  HI, What is push method is JavaScript? I want to know its use with example. What is use of push in javascript.... You can use the push method to add data into existing array. Check example
what is use of push in javascript
what is use of push in javascript  HI, What is push method is JavaScript? I want to know its use with example. What is use of push in javascript.... You can use the push method to add data into existing array. Check example
What is the use of Hibernate?
What is the use of Hibernate?  Hi All, Can anyone tell me what is Hibernate. For what purpose it is used? What are advantages and disadvantes of Hibernate? ThanksADS_TO_REPLACE_1   Hi, Read it at Hibernate advantages
What is the use of CASCADE CONSTRAINTS?
What is the use of CASCADE CONSTRAINTS?   What is the use of CASCADE CONSTRAINTS?   Hi, The CASCADE CONSTRAINTS clause drops all referencial integrity constraints that refer to the primary and unique keys defined
What is the use of Hibernate is used?
What is the use of Hibernate is used?  Hi, What is the use of the Hibernate framework? Thanks   Hello, Hibernate is the ORM framework which is used for saving, retrieving and querying the data from Java program
What is the use of DBCC commands?
What is the use of DBCC commands?  What is the use of DBCC commands?   Hi, DBCC stands for database consistency checker. We use these commands to check the consistency of the databases, i.e., maintenance, validation
What is the use of data science?
What is the use of data science?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: What... so that I can learn the topic "What is the use of data science?"
What is the use of JDK
What is the use of JDK  Hi, What is the use of JDK? Is JRE same as JDK? Thanks   What is the use of JDK and why it?s so important... is the most famous one. Why is JDK used and what makes the version of java so
what is the use of Spring Framework
what is the use of Spring Framework  Hi, I am new to spring... to learn the Spring framework. First of all I want to know the real use...   Hi, You will find more details at: Why to use Spring Framework
servlet
servlet  what are the methods and interfaces in the servlet api ?   Servlet Tutorials
servlet
servlet  i want to use servlet application on my web page then what should i do. I have already webspace.   Hi Friend, Please visit the following link:ADS_TO_REPLACE_1 Servlet Tutorials Thanks
servlet
servlet  what are the all necessary configuration to run a servlet
Context binding
Context binding  What is meant by Context binding?   A binding context is an object that holds data that you can reference from your... parameter you supplied to ko.applyBindings(viewModel). Then, each time you use
Sitemap Java Servlet Tutorial Section
| Context attributes in Servlet | Client Auto Refresh in Servlets | Use Log... is a Container | What is servlet? | Methods of Servlet |  Life Cycle... Redirect in Servlet | Random Redirector | Servlet Context | Servlet
i want to do a project using jsp and servlet....What are all the materials i need to study
i want to do a project using jsp and servlet....What are all the materials i need to study   i want to do a project using jsp and servlet....What are all the materials i need to study ?   Please visit the following

Ads