-2

I would like to create a Java Servlet to allow an Android device to post photos. Where should I begin? Should I use the Apache common fileupload library?

I know how to create a servlet, basically like this right:

@WebServlet(name = "UploadServlet")
public class UploadServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}

(I'm new to Java and web development.)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
EyeQ Tech
  • 7,198
  • 18
  • 72
  • 126

1 Answers1

2

It seems you're using Servlet API 3.0, so there is a dedicated annotation for tagging methods which manage file upload: javax.servlet.annotation.MultipartConfig.

A good tutorial / example is How to write upload file servlet with Servlet 3.0 API.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Kartoch
  • 7,610
  • 9
  • 40
  • 68