Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Which method is correct??

 
trupti nigam
Ranch Hand
Posts: 627
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question ID :994865414562
Which interface and method should be used to retrieve Servlet initialization parameter values?
1)ServletConfig.getParameter(String name)
2)ServletConfig.getInitParameter(String name)
3)ServletContext.getInitParameter(String name)
4)ServletConfig.getInitParameters(String name)
5)ServletConfig.getInitParameterNames(String name)
The correct answer given is 2.
But I think 3 can also be a correct answer.
Choose only one answer..
thanks
Trupti
 
Jagdeep Singh
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Answer (2) is correct. You can not choose (3) because it returns the value of the named context-wide initialization parameter available to an entire "web application". For example, it can provide a webmaster's email address.
 
Hafizur Rahman
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ServletConfig.getInitParameter(String name) gives <init-param>. init-param is specified for individual servlet. Only that servlet can use it.
ServletContext.getInitParameter(String name)
gives <context-param>. context-param is for the total context- all servlets/jsp pages under this context can use it.
--------------
Hafizur Rahman
SCJP
[ November 10, 2002: Message edited by: Hafizur Rahman ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic