i got something like this in my html page:
<form method="post" action="UploadServlet"
enctype="multipart/form-data">
<input type="file" name="file" size="60" /><br />
<input type="text" name="idPicture" value="{{selectedStudent.id}}">
<br /> <input type="submit" value="Upload" />
</form>
and the 4th line is the problem...without that line, my code just uploads the file i selected...and all works...
and then, i just add that simple line to the code, and it returns
java.lang.IllegalStateException: UT000018: Form value is a String, use getValue() instead
and in the servlet, there is nothing that consumes that parameter...
later i placed the following code in comments...
String idPicture = request.getParameter("idPicture").toString();
PrintWriter out = response.getWriter();
out.println(idPicture);
and it is still in comments....i just added the new input field.... and i dont know what to do
here is the code:
@WebServlet("/UploadServlet")
@MultipartConfig
public class UploadServlet extends HttpServlet {
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
//here was my code in comments i added above
// gets absolute path of the web application
String appPath = "C:/.../workspace/CreditCardWEB/WebContent/images/";
// constructs path of the directory to save uploaded file
String savePath = appPath + File.separator;
// creates the save directory if it does not exists
File fileSaveDir = new File(savePath);
if (!fileSaveDir.exists()) {
fileSaveDir.mkdir();
}
for (Part part : request.getParts()) {
String fileName = extractFileName(part);
part.write(savePath + File.separator + "studImg100.jpg");
//here is where the number is needed...
//i want to create a file with the number in its name
}
}
Still, i dont know where the error is
I hope u can help me...