The code sample below can be places in a Servlet to create a File object of the path supplied by the HTML caller form.
PrintWriter out = res.getWriter();
String selectedImg = req.getParameter("imagepath");
File file = new File (selectedImg);
out.println("File size is :" + file.length());