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

 
 


Nagendran
what is the use of servlet context
1 Answer(s)      a year ago
Posted in : Servlet Interview Questions

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>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 Pages:
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
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
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
Servlet Context
Servlet Context  Defined Servlet Context
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
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
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 is Application Context?
What is Application Context?  Hello, What is Application Context? Thanks
Spring Context - Writing Application Context
-hibernate.xml). This file is used by context loader servlet to initialize the Spring... servlet has its own child context that is independent of that of any other servlet... in the web.xml file to load the Spring context though Spring's context loader 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 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
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      ... the reference of the ServletContext to the context init parameters. The servlet and jsp...;ContextMapping</servlet-class> </servlet> <context-param>
what is web .config method
context is used but not ServletConfig what is use of the servletconfig...what is web .config method  servlet container what is difference... or servlet as setAttribute can be accessed with getAttribute() What
Getting Context Parameter Names
with the servlet container. There is only one Servlet Context for the entire web... of the ServletContext to the context init parameters. The servlet and jsp which...;/url-pattern> </servlet-mapping> <context-param> <
How Use of Tomact - JSP-Servlet
How Use of Tomact  Dear Sir, I am using weblogic Application server of BEA. But I am not able use the Apache Tomcat.I have been set the classpath=C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar
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
How Use of Tomact - JSP-Servlet
How Use of Tomact  Dear Sir, Pervious My Question is: I am using weblogic Application server of BEA. But I am not able use the Apache Tomcat.I...\common\lib\servlet-api.jar;. and path=C:\Program Files\Java\jdk1.5.0_05\bin;C
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
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
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: Servlet Tutorials 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
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 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
JNDI Context
obtain a JNDI naming context and then use the bind() and lookup() methods to store... an environment-naming context that can be accessed using the JNDI API. It also... context that contains the resource (a Java object). The java.naming.Context
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
Servlet
Servlet  What is the actual use of servlets in programming?  Hi Friend, Servlets are the server side component. It acts as a controller. It can handle multiple requests concurrently, and can synchronize requests.The
servlet question on web application
What is servlet context?   What is servlet Context? Given me an example
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. We use javax.servlet and javax.servlet.http
Servlet Interview Questions - Page 2
your servlet to be initialized when context is loaded, you have to use a concept...: What mechanisms are used by a Servlet Container to maintain session information... information to maintain the session. Question: What do you understand by servlet
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
fileuploadcode - JSP-Servlet
() is used,when i use it config is not visible ie it is not recognised what can i do  you have to specify context in your Deployment descriptor under you web server. context name
Sitemap Java Servlet Tutorial Section
in Servlet | Client Auto Refresh in Servlets | Use Log in Servlet Context... is a Container | What is servlet? | Methods of Servlet |  Life Cycle... in Servlet | Random Redirector | Servlet Context | Servlet Context Listener
servlet session - JSP-Servlet
servlet session  how can i restrict number of users by 10 using HttpServletListener Hi, You can use application context and then increment...,You can use application context and then increment the counter if new user logs
servlets - Servlet Interview Questions
is deployed and after that only the context is available to each servlet in the web...%20ServletConfig http://www.roseindia.net/servlets/use-log-servlet-context.shtml... is,what is the difference between servletcex and servletconfig(full flezed
Servlet
Servlet  What is Servlet
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 - Servlet Interview Questions
servlet  what is the use of load-on-startup?  Generally, the servlet container will load the servlet class and create servlet object when it receives the first request call for that particular servlet. But, by using
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 Bandwidth or Download
What is Bandwidth or Download?  In this article you will learn... in the web hosting world.  What is Bandwidth? Bandwidth is a measurement... of bandwidth options in their plans. In the context to the web hosting, bandwidth
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
Servlet: What is it
What is Servlet? The Servlet is a class that is written in Java programming.... It interacts with clients via request-response programming model. Servlet... by it. For such applications, Java Servlet technology defines HTTP-specific servlet classes. A web
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
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 and Timer - JSP-Servlet
Servlet and Timer  Hi EveryOne, I have a servlet application,that is working fine. What i want is that my servlet...; response.setHeader("Refresh","60");   Hi friend, use
servlet
servlet  what are the methods and interfaces in the servlet api ?   Servlet Tutorials

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.