views:

84

answers:

1

i am using this reference in jsp .i am able to call functions like

this.getServletConfig();

can anyone pls tell me for which servlet its returning servletconfig object.and which object its refering to?

if it is servlet object it is refering to from which requestdispatch was dn to this jsp page. then it shd return value of these parameters which i am able to access in servlet code. but its returning null.

   out.print("<br>"+this.getInitParameter("GmailId"));
   out.print("<br>"+this.getServletConfig().getInitParameter("GmailId"));


web.config file


   <servlet>
    <description></description>
 <display-name>MyServlet</display-name>
 <servlet-name>MyServlet</servlet-name>
 <servlet-class>MyServlet</servlet-class>
 <init-param>
  <param-name>GmailId</param-name>
  <param-value>sahilvk87</param-value> 
 </init-param>
 <init-param> 
  <param-name>YahooId</param-name>
  <param-value>sahilvk11</param-value>
 </init-param>
</servlet>
<servlet-mapping>
 <servlet-name>MyServlet</servlet-name>
 <url-pattern>/MyServlet</url-pattern>
</servlet-mapping>
<context-param>
<param-name>GlobalName</param-name>
<param-value>Sahil Garg</param-value>
</context-param>


+2  A: 

The servlet that is generated for the JSP page.

Bruno Ranschaert
but if it is so then it should return me init-parameter corresponding to servletConfig for the Servlet.but its not able to do so.however m able to access those parameters in servlet code.
Maddy.Shik
oh yes i got it.for every jsp page a servlet is generated that is different from servlet from which i called requestDispatch().
Maddy.Shik
Did you associate a servlet name with the jsp in the web.xml?
Bruno Ranschaert