| Author |
Doubt in getInitParameter( String name )
|
Balasubramani Dharmalingam
Ranch Hand
Joined: Dec 06, 2004
Posts: 116
|
|
Code 1 : public void doGet( HttpServletRequest req , HttpServletResponse res ) throws IOException , ServletException { PrintWriter out = res.getWriter(); out.print( getInitParameter( "E-mail" ) ); } code 2: public void doGet( HttpServletRequest req , HttpServletResponse res ) throws IOException , ServletException { PrintWriter out = res.getWriter(); out.print( getServletConfig().getInitParameter( "E-mail" ) ); } in code 1 i have used getInitParameter() method of Servlet class. In code 2 i have used getInitParameter() method of ServletConfig class. in both case i am getting the value for the parameter.. is there any difference between these two codes...?
|
Balasubramani SD,<br />SCJP 1.4,SCWCD 1.4,SCJP 5.0<br /><a href="http://sd.balasubramani.googlepages.com" target="_blank" rel="nofollow">www.sd.balasubramani.googlepages.com</a>
|
 |
AmitKumar Jain
Ranch Hand
Joined: Jun 13, 2005
Posts: 95
|
|
|
There's no difference. In both cases, the vaue of init-param for the servlet from web.xml will be retrieved
|
SCJP 1.4 : 91%
SCWCD 1.4 : 95%
SCBCD 1.3 : 95%
SCJP 6 Upgrade : 95%
Next SCBCD 1.5
Man is not finished when he is defeated. He is finished when he quits.
|
 |
Anand Wadhwani
Ranch Hand
Joined: Mar 21, 2005
Posts: 151
|
|
Hi BalaSubramani, Any method of ServletConfig class can directly be invoked in a GenericServlet implementation class because GenericServlet implements ServletConfig interface. Please refer the following thread: http://www.coderanch.com/t/169805/java-Web-Component-SCWCD/certification/Purpose-ServletConfig The thread is remained unanswered, and may be there is no answer too. That's a redundancy in API for programmer's convenience. Hope it helps.
|
SCWCD 1.4<br />---------------------<br />Ability is what you're capable of. <br />Motivation determines what you do. <br />Attitude determines how well you do it.<br />---------------------
|
 |
 |
|
|
subject: Doubt in getInitParameter( String name )
|
|
|