Article View: borland.public.jbuilder.java.language
Article #17046Read HTML/Text files in through a servlet?
From: Scott Ottesen
Date: Tue, 15 Dec 1998 00:00
Date: Tue, 15 Dec 1998 00:00
57 lines
2229 bytes
2229 bytes
Hello-
Is it possible to read HTML or text files in from a servlet? To me, it
seems a servlet is an app and shouldn't have the applet limitations.
I've got all the routines in for doing it, but the servlet can never
find the file (header.txt in this case). It's probably a classpath
issue, but I've placed the file a copy in all classpath locations making
sure it's case sensitive. for example:
String getHTMLTextFile(String sFile)
throws IOException, FileNotFoundException {
try {
String s = "";
String sOut = "";
FileInputStream inputFile = new FileInputStream("header.txt");
BufferedInputStream bufferedFile = new BufferedInputStream(
inputFile );
AsciiInputStream lineOut = new AsciiInputStream( bufferedFile );
while (true) {
s = lineOut.readLine();
if (s != null) {
sOut = sOut + s;
}
else {
inputFile.close();
break;
}
}
return sOut;
}
catch (IOException IOex) {
return IOex.toString();
}
}
Works fine in apps, but can never find the file no matter where I put it
in my server or servlet class paths. What gives?
--------------------------------------------
Scott Ottesen
Programmer/Analyst
Utah Dept. of Comm. & Econ. Dev.
324 S. State St. Suite 500
Salt Lake City, UT 84111
Office: (801)538-8682
Fax: (801)538-8886
EMail: sottesen@dced.state.ut.us
Our Site: http://www.dced.state.ut.us
DCED - Information Technology Services
"As the primary provider of technology
support services we add value to DCED
programs by implementing best practices."
--------------------------------------------
Technical Details
Message-ID:
<36769C14.F122082D@dced.state.ut.us>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,e6a9f12b6bf9916b,start X-Google-Attributes: gidf74b3,public From: Scott Ottesen <sottesen@dced.state.ut.us> Subject: Read HTML/Text files in through a servlet? Date: 1998/12/15 Message-ID: <36769C14.F122082D@dced.state.ut.us> X-Deja-AN: 422556135 Content-Transfer-Encoding: 7bit X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language