Link to home
Start Free TrialLog in
Avatar of ricky06
ricky06

asked on

Urgent, but I haven't points...[How can I write a file on the server side using JSP??]

I need a physical file on my server...the following statement can write within the buffer (I thnik) then display from the buffer.

If JSP cannot write file in the server side, any good suggestion??
I need the *.txt file to plot a generic chart.


String path = request.getRealPath(".");
FileWriter fw = new FileWriter(path + "temp.txt");
BufferedWriter bw = new BufferedWriter(fw);

bw.write("110,120,102,130,25000");
bw.newLine();
bw.write("120,130,120,170,26000");
bw.newLine();
bw.write("130,120,102,130,25000");
bw.newLine();
bw.write("140,130,120,170,26000");
bw.newLine();
bw.write("150,120,102,130,25000");
bw.newLine();
bw.write("160,130,120,170,26000");
bw.newLine();

bw.flush();
bw.close();
fw.close();

FileReader fr = new FileReader(path + "temp.txt");
BufferedReader br = new BufferedReader(fr);
String Line = br.readLine();

while(Line != null){
out.println(Line + "<BR>");
Line = br.readLine();
}

<applet
    code=AStockChart.class
     archive="AStockChart.jar"
    name=cchart
    width=460
    height=400 >
    <param name="file" value="temp.txt"  <----------------This need a physical file on harddisk
     <param name="img" value="backgrnd.gif">
     <param name="nbpoint" value="15">
    <PARAM NAME="FONTNAME" VALUE="Arial">
    <PARAM NAME="FONTSIZE" VALUE="10">
    <PARAM NAME="AP" VALUE="l">
</applet>
Avatar of cheekycj
cheekycj
Flag of United States of America image

you want to use a local file to plot the data?

CJ
local == client or local == server?

CJ
ASKER CERTIFIED SOLUTION
Avatar of cheekycj
cheekycj
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ricky06
ricky06

ASKER

Dear cheekycj,

Thanks for your kindly help, the purpose of my project is:

I've got an applet with completed coding, it need a text file on my server...to plot a stock chart.

Then I need the client browse my server (in JSP) to select some information (such as date) to generate a chart...so I need JSP get the client selected parameter, then WriteFile physically in text format on my server side (harddisk) that can used by the completed applet.

Or any suggestions to complete this task?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
"E:/iPlanet/servers/docs/www/datadir/"  is complete directory path where you r going to store the file
well once the user has selected the data use the code provided by kausiksarkar to write the file.

Then you need to read the file using java.io.File api and push it to the applet.

CJ
Avatar of girionis
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Split points between cheekycj and kausiksarkar

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

girionis
EE Cleanup Volunteer