aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Init parameter null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Init parameter null" Watch "Init parameter null" New topic
Author

Init parameter null

Vinod Kumar
Ranch Hand

Joined: Jan 18, 2002
Posts: 75
web.xml

<!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>TestServlet</servlet-name>
<servlet-class>test.servlets.TestServlet</servlet-class>
<int-param>
<param-name>adminEmail</param-name>
<param-value>mymail@mydomain.com</param-value>
</int-param>
</servlet>

<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/test</url-pattern>
</servlet-mapping>
</web-app>

Servlet Code:

public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {


Enumeration enum = getServletConfig().getInitParameterNames();
String email ="default@web.com";

while (enum.hasMoreElements() ) {

email = getServletConfig().getInitParameter("adminEmail");
}

System.out.println("EMAIL: "+ email);


}
Vinod Kumar
Ranch Hand

Joined: Jan 18, 2002
Posts: 75
I am getting the output as "default@web.com". Could any one help me on this?
I am using Tomcat 5.0

Thanks in advance,
Vinod
Jayanthi Mani
Greenhorn

Joined: Dec 08, 2000
Posts: 25
I am wondering if it is just a typo:
Can u try changing <int-param> to <init-param> and see if it works?

From this:
<int-param>
<param-name>adminEmail</param-name>
<param-value>mymail@mydomain.com</param-value>
</int-param>

To this:
<init-param>
<param-name>adminEmail</param-name>
<param-value>mymail@mydomain.com</param-value>
</init-param>

Thanks,
Jayanthi.
Pabak Nanda
Greenhorn

Joined: Nov 04, 2004
Posts: 24
Jayanthi is right. That was a typo. Again please see the servlet code which is having an infinite loop. As the loop has not any breaking condition, the loop will go for ever.

Thanks,
Pabak
Vinod Kumar
Ranch Hand

Joined: Jan 18, 2002
Posts: 75
Thanks Jayathi, that was a typo! :roll:
 
Consider Paul's rocket mass heater.
 
subject: Init parameter null