if (temp != null)
if (temp != null && temp.length() > 0)
    private void processChooseFile(Context context, HttpServletRequest request,            HttpServletResponse response) throws ServletException, IOException,            SQLException, AuthorizeException    {        File temp = null;        FileUploadRequest wrapper = null;        SubmissionInfo subInfo = null;        boolean ok = false;        String buttonPressed = null;        BitstreamFormat bf = null;        Bitstream b = null;        /*         * To distinguish between an IOException caused by a problem with the         * file upload and one caused by displaying a JSP, we do all the upload         * handling in a try/catch block         */        try        {            // Wrap multipart request to get the submission info            wrapper = new FileUploadRequest(request);            subInfo = getSubmissionInfo(context, wrapper);            buttonPressed = UIUtil.getSubmitButton(wrapper, "submit_next");            if ((subInfo != null) && buttonPressed.equals("submit_next"))            {                // Create the bitstream                Item item = subInfo.submission.getItem();                temp = wrapper.getFile("file");                if (temp != null)                {                    // Read the temp file into a bitstream                    InputStream is = new BufferedInputStream(                            new FileInputStream(temp));                    // do we already have a bundle?                    Bundle[] bundles = item.getBundles("ORIGINAL");                    if (bundles.length < 1)                    {                        // set bundle's name to ORIGINAL                        b = item.createSingleBitstream(is, "ORIGINAL");                    }                    else                    {                        // we have a bundle already, just add bitstream                        b = bundles[0].createBitstream(is);                    }                    // Strip all but the last filename. It would be nice                    // to know which OS the file came from.                    String noPath = wrapper.getFilesystemName("file");                    while (noPath.indexOf('/') > -1)                    {                        noPath = noPath.substring(noPath.indexOf('/') + 1);                    }                    while (noPath.indexOf('\\') > -1)                    {                        noPath = noPath.substring(noPath.indexOf('\\') + 1);                    }                    b.setName(noPath);                    b.setSource(wrapper.getFilesystemName("file"));                    b.setDescription(wrapper.getParameter("description"));                    // Identify the format                    bf = FormatIdentifier.guessFormat(context, b);                    b.setFormat(bf);                    // Update to DB                    b.update();                    item.update();                    ok = true;                }            }        }        catch (IOException ie)        {            // Problem with uploading            log.warn(LogManager.getHeader(context, "upload_error", ""), ie);        }        if (subInfo == null)        {            // In any event, if we don't have the submission info, the request            // was malformed            log.warn(LogManager.getHeader(context, "integrity_error", UIUtil                    .getRequestLogInfo(request)));        }        else if (buttonPressed.equals("submit_cancel"))        {            doCancellation(request, response, subInfo,                    SubmitServlet.CHOOSE_FILE, SubmitServlet.UPLOAD_FILES);        }        else if (buttonPressed.equals("submit_prev"))        {            // Slightly tricky; if the user clicks on "previous,"            // and they haven't uploaded any files yet, the previous            // screen is the edit metadata 2 page. If there are            // upload files, we go back to the file list page,            // without uploading the file they've specified.            if (subInfo.submission.getItem().getBundles("ORIGINAL").length > 0)            {                // Have files, go to list                showUploadFileList(request, response, subInfo, false, false);            }            else            {                // No files, go back to last edit metadata page            	Collection c = subInfo.submission.getCollection();            	int lastPage = EDIT_METADATA_1 + 				               inputsReader.getNumberInputPages( c.getHandle() ) - 1;                doStep(context, request, response, subInfo, lastPage);            }        }        else if (buttonPressed.equals("submit_next"))        {            // "Next" pressed - the actual upload was handled above.            if (ok)            {                // Uploaded etc. OK                if (bf != null)                {                    // Format was identified                    showUploadFileList(request, response, subInfo, true, false);                }                else                {                    // Format couldn't be identified                    showGetFileFormat(context, request, response, subInfo, b);                }                context.complete();            }            else            {                // If we get here, there was a problem uploading, but we                // still know which submission we're dealing with            	showProgressAwareJSP(request, response,	subInfo,            	 	  	     "/submit/upload-error.jsp");            }        }        else        {            doStepJump(context, wrapper, response, subInfo);        }        // Remove temp file if it's still around        if (temp != null)        {            temp.delete();        }    }