0

I want to develop a java dynamic page for uploading images and another one for loading those images from the specified folder. Since the images are important for the users it is not acceptable to lose them every time I recompile. My upload parts is working fine but the load part is not.

Here's my code for the loading part:

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    request.setCharacterEncoding("UTF-8");
    ServletOutputStream out = response.getOutputStream();
    FileInputStream fin = new FileInputStream("/my/file/path/9DSC01717.JPG"); 
    BufferedInputStream bin = new BufferedInputStream(fin);
    BufferedOutputStream bout = new BufferedOutputStream(out);  
    int k=0;
    while((k=bin.read())!=1) {
        bout.write(k);
    }
    bin.close();  
    fin.close();  
    bout.close();  
    out.close();
}

If that isn't the right way, how can I read an image from a specified folder and display back on a jsp page?

  • 1
    Se if this answer can be helpful: https://stackoverflow.com/a/1812356/3055724 – Duloren Oct 21 '17 at 22:55
  • Possible duplicate of [Simplest way to serve static data from outside the application server in a Java web application](https://stackoverflow.com/questions/1812244/simplest-way-to-serve-static-data-from-outside-the-application-server-in-a-java) – guido Oct 21 '17 at 22:57

0 Answers0