int firstSlash = path.indexOf('/'); int secondSlash = path.indexOf('/', firstSlash + 1);  if (secondSlash != -1)
path = path.substring(1);  try
    protected void doDSGet(Context context,        HttpServletRequest request,        HttpServletResponse response)        throws ServletException, IOException, SQLException, AuthorizeException    {        String handle = null;        String extraPathInfo = null;                DSpaceObject dso = null;        // Original path info, of the form "1721.x/1234"        // or "1721.x/1234/extra/stuff"        // substring(1) is to remove initial '/'        String path = request.getPathInfo().substring(1);                try        {            // Extract the Handle            int firstSlash = path.indexOf('/');            int secondSlash = path.indexOf('/', firstSlash + 1);                        if (secondSlash != -1)            {                // We have extra path info                handle = path.substring(0, secondSlash);                extraPathInfo = path.substring(secondSlash);            }            else            {                // The path is just the Handle                handle = path;            }        }        catch (NumberFormatException nfe)        {            // Leave handle as null        }                // Find out what the handle relates to        if (handle != null)        {            dso = HandleManager.resolveToObject(context, handle);        }                if (dso == null)        {            log.info(LogManager.getHeader(context,                "invalid_id",                "path=" + path));            JSPManager.showInvalidIDError(request, response, path, -1);            return;        }        // OK, we have a valid Handle.  What is it?        if (dso.getType() == Constants.ITEM)        {            // Display the item page            displayItem(context, request, response, (Item) dso, handle);        }        else if (dso.getType() == Constants.COLLECTION)        {            Collection c = (Collection) dso;            // Store collection location in request            request.setAttribute("dspace.collection", c);                        /*             * Find the "parent" community the collection, mainly for             * "breadcrumbs"             * FIXME: At the moment, just grab the first community the             * collection is in.  This should probably be more context sensitive             * when we have multiple inclusion.             */            Community[] parents = c.getCommunities();            request.setAttribute("dspace.community", parents[0]);            // home page, or forward to another page?            if (extraPathInfo == null)            {                collectionHome(context, request, response, parents[0], c);            }            else            {                // Forward to another servlet                request.getRequestDispatcher(extraPathInfo).forward(                    request,                    response);            }        }        else if (dso.getType() == Constants.COMMUNITY)        {            Community c = (Community) dso;            // Store collection location in request            request.setAttribute("dspace.community", c);            // home page, or forward to another page?            if (extraPathInfo == null)            {               communityHome(context, request, response, c);            }            else            {                // Forward to another servlet                request.getRequestDispatcher(extraPathInfo).forward(                    request,                    response);            }        }        else        {            // Shouldn't happen.  Log and treat as invalid ID            log.info(LogManager.getHeader(context,                "Handle not an item, collection or community",                "handle=" + handle));            JSPManager.showInvalidIDError(request, response, path, -1);            return;        }    }