• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlet Context parameters

 
Ranch Hand
Posts: 198
Oracle Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

I am reading Head First Servlet and JSP . and in one of the examples they have used the context parameter in the web.xml , my question is if the context parameters are for the entire application then they should be declared in some tag at application scope and not web.xml .
If i have a simple web-app and i want to add the context parameters where should i declare it (in the web.xml of a servlet , also if we declare the context parameters in the web.xml of a particular servlet what if this servlet is not loaded at all then how will we ever b able to read the context parameters)
 
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
context parameters are for the entire application therefore it is declared in <web-app> ...</web-app> and not inside <servlet> ... </servlet>.

 
ragi singh
Ranch Hand
Posts: 198
Oracle Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no i mean to say the context patameters must be defined in some globally accessible xml in the web-app instead of the web.xml in the servlet
 
Pramod P Deore
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
web.xml is globally accessible xml file. At the start up of your web application web.xml is read first.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ragi singh wrote:my question is if the context parameters are for the entire application then they should be declared in some tag at application scope and not web.xml .


web.xml is the perfect place to declare them.

also if we declare the context parameters in the web.xml of a particular servlet


web.xml declares all servlets. And there is only one web.xml per application.

what if this servlet is not loaded at all then how will we ever b able to read the context parameters)


The context params have nothing at all to do with whether a servlet is loaded or not. Nothing at all. Any context params declared in the web.xml will always be available.
 
ragi singh
Ranch Hand
Posts: 198
Oracle Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah thank you , i got the point .
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic