tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Teh Noranis Mohd Aris <>
Subject How to read file content from servlet?
Date Mon, 14 May 2007 03:57:43 GMT
Dear All,
  I have an applet that sends data name, score and ScoreFile to a servlet that get these data
to be saved in a file. My question is, how can I send these data from the servlet to the applet
(reversed) so that I can use only the data name in processing? Please help. Thank you.
  Yours Sincerely;
  The applet is as follows:
  URL servletUrl = null;
  URLConnection con;
  String servletName = "http://localhost:8080/examples/servlet/ServerSide";
  try {
  servletUrl = new URL(servletName+"?name="+name+"&score="+score+"&ScoreFile="+ScoreFile);
  BufferedReader buf = new BufferedReader(new InputStreamReader(con.getInputStream())); }
  catch(Exception e) {
  System.out.println("Exception caught..."+e); }
  The servlet is as follows:
  String name = request.getParameter("name");
  int score = Integer.parseInt(request.getParameter("score"));
  String ScoreFile = request.getParameter("ScoreFile");
  String fileName = "C:/temp/"+ScoreFile;
FileWriter resultsFile = new FileWriter(fileName,true);
PrintWriter toFile = new PrintWriter(resultsFile,true);
toFile.println(name+" "+score);

Park yourself in front of a world of choices in alternative vehicles.
Visit the Yahoo! Auto Green Center.
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message