• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ServletRequest.getParameter()

 
Matthew Phillips
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?
 
Shashank Tanksali
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
 
R K Singh
Ranch Hand
Posts: 5384
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic