title: When uploading an image on Jelastic, the path does not persist in the database. It works fine on the localhost, however
body: <p>One of the requirements of the system is to be able to upload the profile picture of a user. It works fine in the localhost. The images I upload online are exactly the images that were successfully uploaded on the localhost. What could be the possible causes of such error?</p>
  
  <p>This is the simplified code (the previous code I made was more complex, but it had no code repetition, and it ran faster. I simplified the code in order to trace the problem without luck, however)</p>
  
  <pre><code>@RequestMapping(value = "/patient_dp.it")
  public String uploadPatientDP(HttpSession session, HttpServletRequest request, Model model, @ModelAttribute("form") ArchiveForm form, @RequestParam("id") long id, @RequestParam("key") String key) {
      System.err.println("patient dp");
      String username = session.getAttribute("user").toString();
      session.setAttribute("user", username);
  
      Patient patient = null; 
  
      try {
          patient = patientDao.getPatientById(id);
          MultipartFile file = form.getImages().get(0);           
          String absolutePath = null;
          String relativePath = null;
          InputStream inputStream = null;
          OutputStream outputStream = null;
          String fileName_Original = null;
          if (file.getSize() &gt; 0) {
              inputStream = file.getInputStream();
              if (file.getSize() &gt; 100000) {
                  System.out.println("File Size:::" + file.getSize());
                  return "redirect:/upload_prof_pic_assembler?id=" + id + "&amp;key=" + key;
              }
              fileName_Original = file.getOriginalFilename();
              System.out.println("size::" + file.getSize());
              relativePath = "images/profilepic/" + fileName_Original;
              absolutePath = request.getSession().getServletContext().getRealPath("") + "/" + relativePath;
              outputStream = new FileOutputStream(absolutePath);
              System.out.println("fileName:" + file.getOriginalFilename());
  
              int readBytes = 0;
              byte[] buffer = new byte[100000];
              while ((readBytes = inputStream.read(buffer, 0, 100000)) != -1) {
                  outputStream.write(buffer, 0, readBytes);
              }
              outputStream.close();
              inputStream.close();
  
          }       
  
          patient.setRelativePath(relativePath);
          patient.setFileName(fileName_Original);
          patientDao.update(patient);
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }       
  
      return "redirect:/view_patient_profile.it?id=" + patient.getId();
  }
  </code></pre>
  
  <p>In the upload pic jsp, which works fine</p>
  
  <pre><code>&lt;c:when test="${patient != null }"&gt;
                          &lt;form:form action="patient_dp.it?id=${patient.id }&amp;key=p" method="post" commandName="form" enctype="multipart/form-data"&gt;
                              Select File: &lt;input type="file" name="images[0]" id="image" onSubmit="return Validate();"/&gt;
                              &lt;a href=""&gt;&lt;span class="btn"&gt;&lt;input type="submit" value="Upload" class="btnNew"&gt;&lt;/span&gt;&lt;/a&gt;                     
                          &lt;/form:form&gt;
                      &lt;/c:when&gt;
  </code></pre>
  
  <p>This is an excerpt from the view-patient-profile.jsp file. Since the path of the image does not persist in the online database on Jelastic (mariadb), it diverts to the default image. </p>
  
  <pre><code>&lt;c:choose&gt;
      &lt;c:when test="${patient.getRelativePath() == null || patient.getRelativePath().equalsIgnoreCase('null')}"&gt;
          &lt;img src="resources/images/img_user.jpg" alt=""&gt;
      &lt;/c:when&gt;
      &lt;c:otherwise&gt;
          &lt;img src="${patient.getRelativePath() }" alt="${patient.getPersonInfo().getFirstName()}'s profile picture" /&gt;
      &lt;/c:otherwise&gt;
  &lt;/c:choose&gt;
  </code></pre>