read from file in jsp  
Author Message
nikolaj





PostPosted: 2003-7-4 20:43:00 Top

java-programmer, read from file in jsp I'm develloping a site based on jsp.
In my javacode I want to read from a file located in the document root
of the web application. How do I do this when I dont know the name of
the host.

Should I consider locating the file somewhere else. It should actually
only be accessible from the code of the application.

Thanks for your help.

Nikolaj
 
Chris Smith





PostPosted: 2003-7-4 22:28:00 Top

java-programmer >> read from file in jsp William Brogden wrote:
>
> "Nikolaj" <email***@***.com> wrote in message
> news:email***@***.com...
> > I'm develloping a site based on jsp.
> > In my javacode I want to read from a file located in the document root
> > of the web application. How do I do this when I dont know the name of
> > the host.
> >
> > Should I consider locating the file somewhere else. It should actually
> > only be accessible from the code of the application.
>
> The servlet API provides for this in the ServletContext class. Example:
>
> InputStream in = config.getServletContext().getResourceAsStream(
> "WEB-INF/surveys/survey.properties");

Well, the easier way to access the ServletContext is:

InputStream in = application.getResourceAsStream(...);

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
William Brogden





PostPosted: 2003-7-4 23:21:00 Top

java-programmer >> read from file in jsp
"Nikolaj" <email***@***.com> wrote in message
news:email***@***.com...
> I'm develloping a site based on jsp.
> In my javacode I want to read from a file located in the document root
> of the web application. How do I do this when I dont know the name of
> the host.
>
> Should I consider locating the file somewhere else. It should actually
> only be accessible from the code of the application.

The servlet API provides for this in the ServletContext class. Example:

InputStream in = config.getServletContext().getResourceAsStream(
"WEB-INF/surveys/survey.properties");

WBB




----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---