This is the code i used to download the image and saved.Can anyone suggest what else i have to do or what i missed here?? thanks in advance
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
BufferedWriter writer = null;
InputStream in = new BufferedInputStream(request.getInputStream());
try {
byte[] buffer = new byte[100000];
int n = -1;
while ((n = in.read(buffer)) >= 0) {
out.write(buffer, 0, n); // used for image
}
out.close();
byte[] res = out.toByteArray();
out.flush();
FileOutputStream fos = new FileOutputStream("D://"+ new SimpleDateFormat("yyyyMMdd_HHmmssss").format(Calendar.getInstance().getTime()) +".jpg");
fos.write(res);
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}