• 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

ServletContext

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why is it that getParameterValues is there only in HttpServletRequest and not in ServletContext?What if I want to associate multiple values with the same name in Context?
 
author
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Renu,

The term "parameter" is overloaded in the servlet world. It can mean "HTTP request parameter" which are the name/value pairs from the HTML form that the user enters. It can also mean "servlet initialization parameter" which are the name/value pairs from the deployment descriptor in the <servlet> definitions. It can also mean "context initialization parameter" which are the name/value pairs from the deployment descriptor in the <context-param> definitions.

The ServletRequest.getParameterValues() method is for retrieving "request parameters" not for retrieving initialization parameters.

HTH,
Bryan
[ December 03, 2006: Message edited by: Bryan Basham ]
 
Renu Radhika
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But what if I have added an attribute in servlet context and want to associate multiple values with it?
 
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Attributes are objects.

If you want to have a single attribute having multiple values you might like to use a String array (you can also use Map, List etc..), put it several string values and set that as an attribute...

String[] abc = {"You", "and", "me"}

request.setAttribute("var", abc);
 
reply
    Bookmark Topic Watch Topic
  • New Topic