InputStream is = bitstream.retrieve();
    protected void doDSGet(Context context, HttpServletRequest request,            HttpServletResponse response) throws ServletException, IOException,            SQLException, AuthorizeException    {    	Item item = null;    	Bitstream bitstream = null;        // Get the ID from the URL        String idString = request.getPathInfo();        String handle = "";        String sequenceText = "";        int sequenceID;        // Parse 'handle' and 'sequence' (bitstream seq. number) out        // of remaining URL path, which is typically of the format:        // {handle}/{sequence}/{bitstream-name}        // But since the bitstream name MAY have any number of "/"s in        // it, and the handle is guaranteed to have one slash, we        // scan from the start to pick out handle and sequence:        // Remove leading slash if any:        if (idString.startsWith("/"))        {            idString = idString.substring(1);        }        // skip first slash within handle        int slashIndex = idString.indexOf('/');        if (slashIndex != -1)        {            slashIndex = idString.indexOf('/', slashIndex + 1);            if (slashIndex != -1)            {                handle = idString.substring(0, slashIndex);                int slash2 = idString.indexOf('/', slashIndex + 1);                if (slash2 != -1)                    sequenceText = idString.substring(slashIndex+1,slash2);                else                    sequenceText = idString.substring(slashIndex+1);            }        }        try        {            sequenceID = Integer.parseInt(sequenceText);        }        catch (NumberFormatException nfe)        {            sequenceID = -1;        }                // Now try and retrieve the item        DSpaceObject dso = HandleManager.resolveToObject(context, handle);                // Make sure we have valid item and sequence number        if (dso != null && dso.getType() == Constants.ITEM && sequenceID >= 0)        {            item = (Item) dso;                    if (item.isWithdrawn())            {                log.info(LogManager.getHeader(context, "view_bitstream",                        "handle=" + handle + ",withdrawn=true"));                JSPManager.showJSP(request, response, "/tombstone.jsp");                return;            }            boolean found = false;            Bundle[] bundles = item.getBundles();            for (int i = 0; (i < bundles.length) && !found; i++)            {                Bitstream[] bitstreams = bundles[i].getBitstreams();                for (int k = 0; (k < bitstreams.length) && !found; k++)                {                    if (sequenceID == bitstreams[k].getSequenceID())                    {                        bitstream = bitstreams[k];                        found = true;                    }                }            }        }        if (bitstream == null)        {            // No bitstream found -- ID was invalid            log.info(LogManager.getHeader(context, "invalid_id", "path="                    + idString));            JSPManager.showInvalidIDError(request, response, idString,                    Constants.BITSTREAM);            return;        }        log.info(LogManager.getHeader(context, "view_bitstream",                "bitstream_id=" + bitstream.getID()));        // Modification date        // TODO: Currently the date of the item, since we don't have dates        // for files        response.setDateHeader("Last-Modified", item.getLastModified()                .getTime());                // Check for if-modified-since header        long modSince = request.getDateHeader("If-Modified-Since");        if (modSince != -1 && item.getLastModified().getTime() < modSince)        {            // Item has not been modified since requested date,            // hence bitstream has not; return 304            response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);            return;        }                // Set the response MIME type        response.setContentType(bitstream.getFormat().getMIMEType());        // Response length        response.setHeader("Content-Length", String                .valueOf(bitstream.getSize()));        // Pipe the bits        InputStream is = bitstream.retrieve();        Utils.bufferedCopy(is, response.getOutputStream());        is.close();        response.getOutputStream().flush();    }