• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Servletconfig and Servletcontext

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Straws are for suckers. Now suck on this tiny ad!
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic