Rajendran,

If you have already managed to read in the properties file using the
java.util.Properties class, be aware that this is already a Hashtable
(Properties inherits from Hashtable), albeit it must contain only strings as
the value corresponding to any key.

In order to read in a properties file,
first, read the JavaDocs for ServletContext.getResource &
ServletContext.getResourceAsStream methods:


<http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/ServletConte
xt.html#getResource(java.lang.String)>

<http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/ServletConte
xt.html#getResourceAsStream(java.lang.String)>

Once you understand how to do this, you simply create a new Properties
object, and instruct it to load the Properties file
from the given InputStream generated by getResourceAsStream.  Something to
the effect of:

<CODE>
        Properties p = new Properties();
        p.load(getServletContext().getResourceAsStream(...));
</CODE>

That should be all there is to it....

-AMT

> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of Rajendran, Rajarajan
> Sent: Friday, May 26, 2000 8:18 AM
> To: [EMAIL PROTECTED]
> Subject: properties file to Hashtable
>
>
> Hi,
>
> I want to read a .properties file through a servlet and get the properties
> and
> set it to a Hashtable. Can anyone please help me out by sample code.
>
> Thank you.
>
> ==================================================================
> =========
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to