Search code examples
javajspservletsservletconfig

jsp:this refers to which object in jsp page 's jave code block <% %>?


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>


Solution

  • The servlet that is generated for the JSP page.