Please, can you help me do the following thing?
 
I have to write a servlet. This servlet must show an HTML form in which the user has to enter name, age and "attach" a picture.
As he click upon "submit" the servlet has to get name, picture and store them in a database (the picture in a directory).
I tried to use method="PUT" in form and method doPut() of HttpServlet but I can't get my servlet go into the doPut method... it "re-prints" the page with the form and does nothing. I have also a log into I try to write a message as I enter doPut, but, it seems the servlet does not enter the method ablsolutely.
 
This is the code:
 
public void doPut(HttpServletRequest req, HttpServletResponse res)
             throws ServletException, IOException
 {
  PrintWriter toBuyer;
  String operation="";
  if (servletPath == null ) servletPath = req.getServletPath();
  toBuyer = res.getWriter();
  res.setContentType("text/html");
  operation = req.getParameter ("operation ");
  if (operation == null) {}
  else if (operation == "testPut")
   {
     // to read the name
      String s = req.getParameter("name");
 
     // to read the picture... is this the way?
      try
      {
       ServletInputStream b = req.getInputStream();
       byte[] ba = null;
       b.read(ba );
      } catch (Exception e) {msg ("excp: "+ e.toString() ); } // msg is a method which writes to log file
 
      ... save the picture and update db
   }
   else res.sendRedirect("http://java.sun.com/");
   toBuyer.close();
 }
 
 
I have to complete this, please help me!!!
Bye
Chris

Reply via email to