I have a servlet that will handle few hundread thousand requests per day.  I
am using the commons FileUpload to loop thru the fields and file items. 
Here is the code 


    public void doPost(HttpServletRequest req, HttpServletResponse res)
            throws ServletException, IOException {

        try {
            DiskFileItemFactory factory = new DiskFileItemFactory();

            ServletFileUpload upload = new ServletFileUpload(factory);
            List<FileItem> items = upload.parseRequest(req);

            for (FileItem item : items) {
                ....
            }
        }
        catch (Exception e) {
            ...
        }
    }

Since the servlet is being called so many times, can I make the
DiskFileItemFactory global static so it won't create the factory object so
many times?  In sum, is DiskFileItemFactory class thread safe?


    DiskFileItemFactory factory = new DiskFileItemFactory();

    public void doPost(HttpServletRequest req, HttpServletResponse res)
            throws ServletException, IOException {

        try {

            ServletFileUpload upload = new ServletFileUpload(factory);
            List<FileItem> items = upload.parseRequest(req);

            for (FileItem item : items) {
                ....
            }
        }
        catch (Exception e) {
            ...
        }
    }

Thanks!

-- 
View this message in context: 
http://n4.nabble.com/Is-DiskFileItemFactory-Thread-Safe-tp1469216p1469216.html
Sent from the Commons - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to