I am running Eclipse Java EE and tomcat for running my webapp. I used the following code to store an image file to the upload/images/profilepics directory:
public String uploadPhoto() {
    try {
        //get path to upload photo
        String filePath = servletRequest.getSession().
                getServletContext().getRealPath("/uploads/profilepics");
        System.out.println("Server path:" + filePath);
        //creating unique picture name
        Map sess = (Map) ActionContext.getContext().get("session");
        Integer uid = (Integer) sess.get("uid");
        String profilePictureName = uid + "-" + 
                MyUtilityFunctions.createVerificationUrl() + this.userImageFileName;
        //update user record
        //tobe done 
        String imgUrl = filePath + profilePictureName;
        ViewProfileModel pofilePictureUpdate = new ViewProfileModel();
        pofilePictureUpdate.updateUserPhotoUrl(imgUrl, uid);
        //create new File with new path and name
        File fileToCreate = new File(filePath, profilePictureName);
        //copy file to given location and with given name
        FileUtils.copyFile(this.userImage, fileToCreate);
    } catch (Exception e) {
        e.printStackTrace();
        addActionError(e.getMessage());
        return INPUT;
    }
    return SUCCESS;
}
after printing filePath I got the following result:
Server Path: /home/bril/webspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/picvik/uploads/profilepics
Now the problem is, I am not able to get the image or if I give the same url to <img src=""> nothing is getting displayed.
Please correct where I am doing wrong.
 
     
     
  
    