• Post Reply Bookmark Topic Watch Topic
  • New Topic

Servletconfig and Servletcontext

 
srinivas sy
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1]Is it mandatory to get Servletconfig object to get servletconfig parameters?**
2]Is it mandatory to get Servletcontext object to get ServletContext parameters?**
3]what is init() or init(ServletConfig) method actually does?**
4]why cant we write init(ServletContext)? why only init(ServletConfig)?**
5]can i write get the ServletContext parameters in init() method ?**
6]for one application how many ServletContext objects needed? wherever i require can i write ServletContext ctx=getServletContext???
7]what does it mean
ServletConfig ctx=getServletConfig();
ServletContext ctx=getServletContext();
i know ServletContext is interface,but this statement mean.
how can we write method is assigning to this interface......///thinking i dont know java..here...

8]----------------------------------
web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">

<servlet>
<description></description>
<display-name>servlet1</display-name>
<servlet-name>servlet1</servlet-name>
<servlet-class>com.web.servlet1</servlet-class>
<init-param>
<param-name>abc</param-name>
<param-value>999</param-value>
</init-param>
<init-param>
<param-name>xyz</param-name>
<param-value>111</param-value>
</init-param>
<init-param>
<param-name>ppp</param-name>
<param-value>120</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>servlet1</servlet-name>
<url-pattern>/servlet1</url-pattern>
</servlet-mapping>
<servlet>
</web-app>

in servlet class directly , able to write
String s=getServletConfig("PARAMETERNAME");
without calling
servletconfig c=getServletConfig();//why is it?
why only for servletconfig they have made it?




Please give me clear idea about these...
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in servlet class directly , able to write
String s=getServletConfig("PARAMETERNAME");
without calling
servletconfig c=getServletConfig();//why is it?


See the documentation for the GenericServlet class in the javax.servlet package.

Specifically the two versions of the init() method and getServletConfig() methods.

Bill

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!