Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Servlet-Interview-Questions what is the use of servlet context
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Nagendran
what is the use of servlet context
1 Answer(s)      2 years and 7 months ago
Posted in : Servlet Interview Questions


what is the use of servlet context


Advertisement
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>userEmail@gmail.com</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:
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
Servlet Context
Servlet Context  Defined Servlet Context
Advertisements
What is Application Context?
What is Application Context?  Hello, What is Application Context? Thanks
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
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 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...;ContextMapping</servlet-class> </servlet> <context-param> <...-value> </context-param> <servlet-mapping> <servlet-name>
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
Spring Context Loader Servlet
Spring Context Loader Servlet   ... (org.springframework.web.context.ContextLoaderServlet) Context Loader Servlet start up... this behavior. If you use such a container, this servlet can be replaced
Servlet Context
Servlet Context      ... the reference of the ServletContext to the context init parameters. The servlet and jsp...;ContextMapping</servlet-class> </servlet> <context-param>
What is the use of friend function?
What is the use of friend function?  What is the use of friend function
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 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 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? Thanks   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 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
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
How to use Servlet and Ajax?
How to use Servlet and Ajax?  How to use Servlet and Ajax
What is use of method overloading and overriding?
What is use of method overloading and overriding?  Method overriding... write same method with different signatures.But I want to know what is the use of these concepts.how to use this type of polymorphism in real time? thanks
context attribute
context attribute  i have writteh the program lyk this ...still error... { res.setContentType("text/html"); PrintWriter out = res.getWriter(); out.println("context... that server is not getting the path of servlet. Anyways, follow these steps: Put
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... whereas Applet runs on Web Browser. Use of Servlet Servlet is used to store
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
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 use of Print or Echo Function in PHP?
What is the use of Print or Echo Function in PHP?  Hi, Can anyone explain what is the use of print or Echo function in PHP? Please provide online reference for this. Thanks,   Hi, Although the use of both Print
what is the use of Hibernate Sessionfactory close() method?
what is the use of Hibernate Sessionfactory close() method?  hi, What is the use of of Hibernate Sessionfactory close() method? Thanks..   Hello, Close() method of Hibernate Sessionfactory destroys the SessionFactory
what is the use of clone() in real time scenario?
what is the use of clone() in real time scenario?  what is the use of clone() in real time scenario?   Hi Friend, Clone() method is used to create and return copy of the object. For more information, visit
How to use web.xml in Servlet 3.0
How to use web.xml in Servlet 3.0 In this tutorial you will learn how to use web.xml in Servlet 3.0. Here I am giving the simple example of a Servlet in which I make a simple servlet class using @WebServlet annotaion into which
Advertisements
 

 

 

DMCA.com