problem with enctype=\"multipart/form-data\" HELP PLEASE!
843841Nov 23 2007 — edited Nov 28 2007Hi Everyone!!! In my FileUploadServlet I use enctype=\"multipart/form-data\" encryption. I have textbox in which I want to write comment. I wrote it an when I press Upload button the parameter is null and don't show my comment! I think the problem is in enctype=\"multipart/form-data\" Can you tell what i need to do????
The code of doPost method:
private void sendPage(HttpServletRequest req, HttpServletResponse res,
String token) throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("<HTML><HEAD><TITLE>Aprekjini!</TITLE>");
out.println("</HEAD><BODY bgcolor=#FF0000>");
out.println("<Centrer><big><b>Ielade TEST!</b></big></Center>");
if (token == null) {
out.print("<br>");
out.print("<table><tr>");
out.print("<form method=\"post\" enctype=\"multipart/form-data\">");
out.println("<input type=\"" + "text\" " + "name=\"" + "coment\""
+ ">");
out.println("<input type=\"hidden\" name=\"action\" value=\"do\"/>");
out.print("<td> <input type=\"file\" size=20 name=\"fname\"> </td>");
out.print("<td> <input type=\"Submit\" NAME=\"apply\" value=\"Upload\"> </td> </form>");
out.print("</tr></table>");
} else {
out.println("<br><br>" + req.getParameter("coment"));
out.println("<br><br><img src=" + "http://localhost:8080/files/" + display);
}
out.close();
}
Best regards!