I need to call a servlet via another Java file not via UI. I need to send a csv file along with the request. How can I send the file along with the request which I can access in the servlet.
File myFile = new File("c:\\myfile.csv");
String strFormURL = "http://localhost:8080/Forms/MyFacesServlet/";
url = new URL(strFormURL);
HttpURLConnection httpURLConnection = (HttpURLConnection) url
.openConnection();
httpURLConnection.setDoOutput(true);
httpURLConnection.setRequestMethod("POST");
Please advice how the file (myFile) can be passed along with the servlet call. So that I can access the file in Servlet and call a service to validate the file content.