开发者

How to process uploaded file and for data in same servlet?

I am uploading fi开发者_StackOverflow中文版les using servlets. Now, i want to process some user input/form data in the same servlet. Is that possible? If, its possible means, how?

As far what i know is, doPost() method have an if condition to check whether the request contains mutilpart data and in else block the form processing. How the both if & else block getting execute? I am confused.

Any suggestions!!!


Those if-else blocks are in a for or while loop over List<FileItem>, right? The loop just keeps repeating the piece of if-else code until there are no items anymore.

I must however admit that the FileItem is a misleading name. MultipartItem has been a better name.

See also:

  • How to upload files in JSP/Servlet
  • for statement tutorial
  • while statement tutorial


Since you're using Servlet 3.0, you'll be pleased to know that it comes with Asynchronous Processing. With asynchronous processing, a thread is called to handle a resource and return back to the container without being blocked.

There is a good explanation on JavaWorld which explains Asynchrous Processing. I don't know if that's what you're looking for.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜