jsp:this 指的是 jsp 页面的 jave 代码块 <% %> 中的哪个对象?
我在 jsp 中使用此引用。我能够调用像
this.getServletConfig();
这样的函数 谁能告诉我它返回的 servletconfig 对象是哪个 servlet 以及它引用的是哪个对象?
如果它是 servlet 对象,则它引用的是来自该 jsp 页面的 requestdispatch。 然后它返回这些参数的值,我可以在 servlet 代码中访问这些参数。 但它返回 null。
out.print("<br>"+this.getInitParameter("GmailId"));
out.print("<br>"+this.getServletConfig().getInitParameter("GmailId"));
web.config 文件
<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>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为 JSP 页面生成的 servlet。
The servlet that is generated for the JSP page.