David,

That works! Thank you so much! : ,

g.

-----Original Message-----
From: Karr, David [mailto:david.karr@;ATTWS.COM]
Sent: Thursday, October 24, 2002 1:44 PM
To: [EMAIL PROTECTED]
Subject: Re: Servlet can't locate file


> -----Original Message-----
> From: Means, Garann R. [mailto:grmeans@;DOC1.WA.GOV]
> Sent: Thursday, October 24, 2002 1:33 PM
>
> My servlet is supposed to read the contents of a file stored
> in the root of
> my webapp. I need to set it up so that the file can be found
> on both Linux
> and windows systems. But no matter what path I type in or
> where I put the
> file, the servlet isn't able to find it. What do I need to
> change? Have I
> missed a config file? Below is a code snippet from the servlet:
>

>         public void doPost(HttpServletRequest request,
> HttpServletResponse
> response)
>                 throws ServletException, IOException {
>                         response.setContentType("text/html");
>                         PrintWriter out = response.getWriter();
>
>                         byte fileIn[] = new byte[500000];
>                         FileInputStream fis = new
> FileInputStream("junk.txt"); // here's the filename

In a servlet, you need to use
"getServletContext().getResourceAsStream(String)" instead of just creating a
FileInputStream.

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

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

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

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to