aspose file tools*
The moose likes JDBC and the fly likes Servlet initparameter not displaying Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Servlet initparameter not displaying " Watch "Servlet initparameter not displaying " New topic
Author

Servlet initparameter not displaying

upanshu vaid
Ranch Hand

Joined: Sep 07, 2012
Posts: 73

Hi Ranch,
I was trying to print the servlet initParameter ,the web.xml is as follows

- <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
- <servlet>
<servlet-name>Ch3 Beer</servlet-name>
<servlet-class>com.example.web.BeerSelect</servlet-class>
- <init-parm>
<parm-name>adminEmail</parm-name>
<parm-value>upanshuvaid@xyz.com</parm-value>
</init-parm>
</servlet>
- <servlet-mapping>
<servlet-name>Ch3 Beer</servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>
</web-app>


my servlet class is

package com.example.web;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class BeerSelect extends HttpServlet
{
public void doPost (HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out=response.getWriter();
out.println("Beer Selection Advice<br>");
String c=request.getParameter("color");
out.println("<br>Got Beer Color"+" "+c);
out.println("<br>");
ServletConfig cfg=getServletConfig();
String c1=cfg.getInitParameter("adminEmail");
out.println(c1);
}
}

but I am getting a null value kindly help

thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42919
    
  68
It's called "param", not "parm". Programming is all about paying attention to detail.
upanshu vaid
Ranch Hand

Joined: Sep 07, 2012
Posts: 73

Thanks for your reply
 
Don't get me started about those stupid light bulbs.
 
subject: Servlet initparameter not displaying