<%@page import="java.io.*, java.net.URLEncoder"%> <% //Opening the standard input for reading the image InputStream is = request.getInputStream(); //Generating random a number for the temporary file int rnd = (new java.util.Random()).nextInt(); rnd = rnd<0 ? -rnd : rnd; //Name of the temporary file String tmpFile = System.getProperty("user.home") + System.getProperty("file.separator") + "tmp"+rnd; //Creating the temporary file File f = new File(tmpFile); while(f.exists()) { rnd = (new java.util.Random()).nextInt(); rnd = rnd<0 ? -rnd : rnd; f.renameTo( new File(System.getProperty("user.home") + System.getProperty("file.separator") + "tmp" + rnd )); } f.createNewFile(); //Opening the temporary file for writing FileOutputStream fout = new FileOutputStream(f); int c; //Reading data from the inpustream and writing into the temporary file while ((c = is.read()) != -1) { fout.write(c); } is.close(); fout.close(); //Sending the temporary file's name to the applet PrintWriter pw = new PrintWriter(response.getOutputStream()); pw.println(URLEncoder.encode(f.getPath())); pw.close(); %>