• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Init Parameters for servlet

 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have defined following init-param in the web.xml.

<servlet>
<description>Init Parmeter Check Servlet</description>
<servlet-name>CheckServeltConfig</servlet-name>
<servlet-class>mypackage.CheckServeltConfig</servlet-class>
<init-param>
<param-name>email</param-name>
<param-value>email1</param-value>
</init-param>
<init-param>
<param-name>name</param-name>
<param-value>Narendra Dhande</param-value>
</init-param>
<init-param>
<param-name>email</param-name>
<param-value>email2</param-value>
</init-param>
</servlet>

The value of getInitParameter("email") method in this servlet is email2.
How and why?.

Also in the HTML FORM action elemet I have to spcify the servlet URI as

/webapplicationName/checkservletconfig , where checkservletconfig is servlet-mappling to the above Servlet. Why we can not exclude the /webapplicationName (i.e. context name) while reffering the servlet from HTML form. The calling HTML is stored in the root of web application.

Thanks
 
Bhumika Thakkar
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
container stores in name,value pair. the third param (email/email2) declaration overrides/replaces the first one (email/email1), thus u see email2 and not email1
 
Bhumika Thakkar
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
have u tried FORM action="/checkservletconfig" ?
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for the quick reply. In the Servlet Specifications it is not clearly specified (regarding first point).

Secondly, I had tried /checkservletconfig but it was giving me URL like
http://localhost:8080/checkservletconfig in browser adress bar. The Context path was missing.

Thanks
 
Vineela Devi
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can u tell me what u have written in ur <servlet-mapping>?
Vineela
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The <servlet-mapping entry is as follow

<servlet-mapping>
<servlet-name>CheckServeltConfig</servlet-name>
<url-pattern>/checkcerveltconfig</url-pattern>
</servlet-mapping>

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic