• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Init parameter null

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jayathi, that was a typo! :roll:
reply
    Bookmark Topic Watch Topic
  • New Topic