Hi Richard,
   Thanks a lot for the reply.I did exactly as u suggested.But even then
I am unable to get the information.
  My web.xml file:
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd";>

<web-app>
  <servlet>
    <servlet-name>
       Test
    </servlet-name>
    <servlet-class>
        InitTest
    </servlet-class>
    <init-param>
        <param-name>
           host
        </param-name>
        <param-value>
           basie.ittc.ku.edu
        </param-value>
    </init-param>
  </servlet>
</web-app>

My Servlet:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class InitTest extends HttpServlet {

  public String host;
  public String name;

  public void init(ServletConfig config) throws ServletException {
    super.init(config);
    // host = getInitParameter("host");
    host = config.getInitParameter("host");
    name = getServletConfig().getServletName();
  }

  public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException,IOException {
    resp.setContentType("text/html");
    PrintWriter out = resp.getWriter();
    out.println("<html><head><title>Hello</title></head>");
    out.println("<body>this is string: "+host+" </body>");
    out.println("</html>");
  }
}


My Servlet output:
this is string: null

Am i doing any mistake anywhere.Please help me....
Thanks .......
Murthy.




On Fri, 2002-05-10 at 22:39, Richard Yee wrote:
> Murthy,
> What entries did you use in the web.xml file and what code did you use in
> your servlet to retrieve the parameters.
> In the web.xml inside your servlet section, you should have an entry like this
>          <init-param>
>                  <param-name>
>                          yourParamName
>                  </param-name>
>                  <param-value>
>                          yourParamValue
>                  </param-value>
>          </init-param>
>
> In your servlet's init() method, you should then have code like this:
>
> String param;
>
> public void init(ServletConfig config) {
>    super.init(config);
>    param = config.getInitParameter("yourParamName");
>    if (param == null) {
>      param = DEFAULT_PARAM_VALUE;   // this needs to be defined somewhere else.
> }
>
>
> Regards,
>
> Richard
>
>
>
> At 08:58 PM 5/10/2002 -0500, you wrote:
> >Hi all,
> >    I am  new to servlet programming.I installed tomcat server version
> >4.0 on my Linux box and running the servlets.
> >     I am trying to initialse the values to the servlets.This is how i
> >did it:
> >     in tomcat-dir/webapps/ROOT/WEB-INF/web.xml    I set all the values
> >for the initialization parameters.
> >    In tomcat-dir/webapps/ROOT/WEB-INF/classes I created a servlet and I
> >am trying to access the initialised values.
> >    But for some reason it is not able to access the initialised values.I
> >am even re-starting the server before I am running the servlet.
> >
> >    Can anyone please help me in this aspect.............
> >Thanks.
> >--
> >*****************************************************************************
> >Murthy Kakarlamudi                      Graduate Research Assistant,ITTC
> >Advisor: Dr.Perry Alexander
> >
> >"Every morning, I get up and look through the 'Forbes' list of the
> >richest people in America.  If I'm not there, I go to work"
> >******************************************************************************
> >
> >___________________________________________________________________________
> >To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> >of the message "signoff SERVLET-INTEREST".
> >
> >Archives: http://archives.java.sun.com/archives/servlet-interest.html
> >Resources: http://java.sun.com/products/servlet/external-resources.html
> >LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
--
*****************************************************************************
Murthy Kakarlamudi                      Graduate Research Assistant,ITTC
Advisor: Dr.Perry Alexander

"Every morning, I get up and look through the 'Forbes' list of the
richest people in America.  If I'm not there, I go to work"
******************************************************************************

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to