In fact, Mr. Hao's code works perfectly. The file
"economic.txt" is just located under your
<tomcat_home>\bin.
KC
--- Luba Powell <[EMAIL PROTECTED]> wrote:
> Here is the example that works:
>
> <html>
> <body>
> <center>
>
> <%@ page import="java.util.*, java.io.*" %>
>
> <%
> Properties props = (Properties)
> application.getAttribute("PROPERTIES");
>
> if (props == null)
> {
> props = new Properties();
> props.load(new
>
FileInputStream("c:/tomcat4/webapps/myapp/application/props.txt"));
> application.setAttribute("PROPERTIES", props);
> out.println("<h3>Property file is loaded</h3>");
> }
> else
> {
> Enumeration enum = props.propertyNames();
> while (enum.hasMoreElements())
> {
> String name = (String) enum.nextElement();
> out.println ( "name: " + props.getProperty(name)
> + " value: " + props.getProperty(name) +
> "<br>"
> );
> }
> }
>
> %>
>
> </center>
> </body>
> </html>
>
>
> ----- Original Message -----
> From: "Foo Shi Hao" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, June 14, 2001 8:45 AM
> Subject: Using JSP to Save file
>
>
> > Hey all~!
> > Got something to ask. I'm running a simple jsp
> page as shown below. It has
> no errors but the file is not being
> written/created...any ideas?
> >
> > <%@ page import="java.io.*"%>
> > <html>
> > <head><title>File Saver</title></head>
> > <body>
> > <%
> > PrintWriter textFile = null;
> > try
> > {
> > textFile = new PrintWriter(new
> > FileOutputStream("economic.txt"));
> > }
> > catch(IOException e)
> > {
> > System.out.println("File I/O Error.");
> > }
> > textFile.println("Testing Phase");
> > textFile.close();
> > %>
> > </body>
> > </html>
> > --
> >
> > Get your free email from www.doramail.com with 30
> Megs of disk space in
> webhosting and e-mail storage!
> >
> >
> >
> >
> >
> > Powered by Outblaze
>
__________________________________________________
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/