Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Is there any differance b/w getting servlet context from
servlet config and session? if yes then what is that?

Answers were Sorted based on User's Feedback



Is there any differance b/w getting servlet context from servlet config and session? if yes then w..

Answer / nisha

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 ?    13 Yes 4 No

Is there any differance b/w getting servlet context from servlet config and session? if yes then w..

Answer / sandhya

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 ?    8 Yes 3 No

Is there any differance b/w getting servlet context from servlet config and session? if yes then w..

Answer / frank tamaguchi

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 ?    3 Yes 1 No

Is there any differance b/w getting servlet context from servlet config and session? if yes then w..

Answer / rajendra singh bisht

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 ?    4 Yes 3 No

Is there any differance b/w getting servlet context from servlet config and session? if yes then w..

Answer / katamraju

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 3 No

Is there any differance b/w getting servlet context from servlet config and session? if yes then w..

Answer / thennavan.m

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

Is there any differance b/w getting servlet context from servlet config and session? if yes then w..

Answer / koti

servlet context:servletcontext is only one web web
application object
servlet config: servlet config is multiple object in
webapplication

Is This Answer Correct ?    9 Yes 13 No

Post New Answer

More Servlets Interview Questions

How can we refresh automatically when new data is entered into the database?

0 Answers  


When should you prefer to use doget() over dopost()?

0 Answers  


What is difference between server and servlet?

0 Answers  


What are the parameters of the service method ?

2 Answers  


Write the code to get the server information in servlet.

0 Answers  


When servlet object is created?

0 Answers  


How can you create a session in servlet?

0 Answers  


How can I send user authentication information while making URL Connection?

0 Answers  


What are the security issues in Servlets?

2 Answers  


How forward () method is different from send redirect () method?

0 Answers  


Why filter is used in servlet?

0 Answers  


How to read request headers from servlets?

0 Answers  


Categories