ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Java J2EE  >>  Java Related  >>  Servlets
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
Is there any differance b/w getting servlet context from 
servlet config and session? if yes then what is that?
 Question Submitted By :: Vijay
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Is there any differance b/w getting servlet context from servlet config and session? if yes then what is that?
Answer
# 1
servlet context:servletcontext is only one web web 
application object
servlet config: servlet config is multiple object in 
webapplication
 
Is This Answer Correct ?    8 Yes 9 No
Koti
 
  Re: Is there any differance b/w getting servlet context from servlet config and session? if yes then what is that?
Answer
# 2
Servlet config is one per servlet and servlet context is one for
the whole webapplication. 

Servlet config is used to pass deploy time information to servlet
where servlet context can be used to get information about the
container,server.
 
Is This Answer Correct ?    8 Yes 2 No
Nisha
 
 
 
  Re: Is there any differance b/w getting servlet context from servlet config and session? if yes then what is that?
Answer
# 3
YES,There is some difference,when we deploy the web 
application the web container will create the Context 
object and when we load the servlet class then container 
will create config object,so for each web application web 
container will create one servlet context obj and for each 
servlet web container will create servlet config object.

Generally we use this objects to avoid the hardcoding,we 
declare this variables in deployment descriptor,we declare 
context parameters under web-app tag so that all servlets 
can use this parameter values ,and config parameters under 
servlet tag so that only specific servlet can use this 
parameter values,in simple way context object is like 
global object and config obj is like local obj.
 
Is This Answer Correct ?    3 Yes 3 No
Sandhya
 
  Re: Is there any differance b/w getting servlet context from servlet config and session? if yes then what is that?
Answer
# 4
Yes, some difference is there b/w servletconfig , servlet
context and session.
ServletContext:This is an interface created by webcontainer
based on class provided by webcontainer wendor,the
webcontainer will be create ServletContext Obj for the whole
web-application.
ServletConfig:This also an inteface and created by
webcontainer based on class provided by webcontainer vendor,
webcontainer creates servlet config obj forevery resource
that is available in webapplication.
session:session can be used to develop stateful application.
 
Is This Answer Correct ?    3 Yes 2 No
Katamraju
 
  Re: Is there any differance b/w getting servlet context from servlet config and session? if yes then what is that?
Answer
# 5
You can get reference to ServletContext through ServletConfig. HttpSession does not provide a reference to ServletContext object.

To get a ServletContext object use

getServletConfig().getServletContext();

or you can call directly getServletContext() bcoz GenericServlet class implements ServletConfig interface also.
 
Is This Answer Correct ?    0 Yes 2 No
Rajendra Singh Bisht
 
  Re: Is there any differance b/w getting servlet context from servlet config and session? if yes then what is that?
Answer
# 6
The ServletContext returned from ServletConfig and from
HttpSession are the same instance, the one instance that
exists while the web application is running. You can confirm
it with a debugger.

The main differences though are that you get a reference to
ServletConfig when in a Servlet and you get a reference to
an HttpSession from an HttpServletRequest.

You can get a reference to a ServletContext from a
FilterConfig when in a Filter.

If you are not in a Servlet and don't want to create an
HttpSession through a call to
HttpServletRequest.getSession() to be able to get a
reference to a ServletContext then create a Filter which
puts a reference to the ServletContext in a request attribute.
 
Is This Answer Correct ?    1 Yes 0 No
Frank Tamaguchi
 
  Re: Is there any differance b/w getting servlet context from servlet config and session? if yes then what is that?
Answer
# 7
YES.

ServletContext(): To communicate with the Servlet Container.
                  Eg: What server to running on the 
                      Environment.Then when sever is 
                      started,who is login the server all
                      the information to store the 
                      "Event log"file ie log4j.  

ServletConfig(): Pass the configuration information to the 
                 Server to the servlet.  

Session():       Session is a Object to track
                 the user interaction with
                 the web application across multiple
                 HttpSession.
 
Is This Answer Correct ?    0 Yes 0 No
Thennavan.m
 

 
 
 
Other Servlets Interview Questions
 
  Question Asked @ Answers
 
How we can check in particular page the session will be alive or not Symbiosis4
How many Cookies can a host support?  2
can we create more than ServletContext and ServletConfig in your application Patni5
can v create a constructor 4 servlet? Satyam4
How threads are implemented in servlets?  3
Name the webserver that is used to run Servlets?  5
How to debug a servlet?  1
What is the difference between Get and Post Method? T3-Softwares5
how the server will know its the same jsp page? HCL1
what are the disadvantages of cookies?  2
what are the way a client can be tracked? IBM1
What are the exceptions thrown by Servlets? Amplify-Mindware3
What are the parameters of the service method ?  2
what is meant by Transaction Isolation Levels? IBM2
which type of data passing is used in realtime?  1
waht is the main diference b/w servelts and JSP ? HCL5
where the generated jsp source file are stored? HCL5
What is Servlet Context?  4
How do you pass the data from one servlet to another servlet? HCL6
where the session data will stored?  1
 
For more Servlets Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com