tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matt Egyhazy" <mw...@virginia.edu>
Subject Re: Error reading init-params
Date Sun, 10 Feb 2002 18:53:54 GMT
i just use String thisString = getInitParameter("nameofparameter");

matt
----- Original Message ----- 
From: "Dominik Jednoralski" <tomcat@lime-design.de>
To: <tomcat-user@jakarta.apache.org>
Sent: Sunday, February 10, 2002 11:49 AM
Subject: Error reading init-params


> Hey Guys,
> 
> I have a problem with getting my init-params from the web.xml-file. I'm
> using
> Tomcat 4, and these are the parameters I inserted into the
> webapps/root/web-inf/web.xml-file:
> 
> <web-app>
>   <servlet>
>     <servlet-name>ShowMsg</servlet-name>
>     <servlet-class>limeservlets.ShowMessage</servlet-class>
>     <init-param>
>       <param-name>message</param-name>
>       <param-value>Nerv-Serv</param-value>
>     </init-param>
>     <init-param>
>       <param-name>repeats</param-name>
>       <param-value>5</param-value>
>     </init-param>
>   </servlet>
> </web-app>
> 
> Now I failed to read these parameters with the follwing servlet:
> 
> 
> package limeservlets;
> 
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.io.*;
> 
>  public class ShowMessage extends HttpServlet {
>     private String message;
>     private String defaultMessage = "Leider keine Nachricht.";
>     private int repeats = 1;
> 
>     public void init (ServletConfig config) throws ServletException{
>        super.init(config);
>        message = config.getInitParameter("message");
>        if (message == null) {
>        message = defaultMessage;
>        }
> 
>        try {
>        String repeatString = config.getInitParameter ("repeats");
>        repeats = Integer.parseInt(repeatString);
>        } catch (NumberFormatException nfe){}
>     }
> 
>     public void doGet (HttpServletRequest request, HttpServletResponse
> response)
>        throws ServletException, IOException{
>     response.setContentType("text/html");
>     PrintWriter out = response.getWriter();
>     String title = "The Servlet which shows a message!";
> 
>     out.println(ServletUtilities.headWithTitle(title) +
>     "<body bgcolor=#fdf5f6>\n<h1>"+ title + "</h1><br>");
>     for (int i = 0; i < repeats; i ++) {
>     out.println(message + "<br>");
>     }
>     out.println("</body></html>");
>     }
>  }
> 
> 
> Does anyone know the reason for that? I for myself don't have a clue- I'm
> not really into configuring servers...
> 
> Dominik Jednoralski
> 
> 
> --
> To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
> Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>
> 


--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message