Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

ServletRequest.getParameter()

 
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The study guide I am reading states that initialization parameters from web.xml can be retrieved using the above method. I have never been able to get this to work. Is the study guide I am reading wrong or am I missing something?
 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use
getServletConfig().getInitParameter("myParameter");
to get servlet specific initialization parameter.
Use
getServletContext().getInitParameter("myParameter");
to get web application initialization paramter.
When you do a request.getParameter("myParameter"), you will get the value for myParameter only if the parameter is part of your HttpRequest like the one below.
http://www.myhost.com/servlet/MyServlet?myParamter=myValue
-Shashank
 
Ranch Hand
Posts: 5390
1
Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont think you can get parameter value with this from web.xml as it is being called on ServletRequest object.
CMIW
TIA
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't think you could get an initialization parameter through req.getParameter, but I just wanted to double check and make sure that I wasn't missing something. Thanks.
 
WARNING! Do not activate jet boots indoors or you will see a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic