items   = new Item[0]; handles = (List)new ArrayList();
resultsItems       = new Item[0]; resultsCommunities = new Community[0]; resultsCollections = new Collection[0];  itemHandles      = (List)new ArrayList(); communityHandles = (List)new ArrayList(); collectionHandles= (List)new ArrayList();
    protected void doDSGet(Context context,        HttpServletRequest request,        HttpServletResponse response)        throws ServletException, IOException, SQLException, AuthorizeException    {        // Get the query        String query = request.getParameter("query");        // Get the location parameter, if any        String location = request.getParameter("location");        String newURL;        // If there is a location parameter, we should redirect to        // do the search with the correct location.        if (location != null && !location.equals(""))        {            // Do the redirect            response.sendRedirect(response.encodeRedirectURL(                    request.getContextPath() + location +                    "simple-search?query=" + query));            return;        }        // For the results        List handles;        // Build log information        String logInfo = "";        // Get our location        Community community = UIUtil.getCommunityLocation(request);        Collection collection = UIUtil.getCollectionLocation(request);        Item[] items;//        String[] handles;        // Perform the search        try        {            if (collection != null)            {                logInfo = "collection_id=" + collection.getID() + ",";                request.setAttribute("collection", collection);                request.setAttribute("community", community);                handles = DSQuery.getItemResults(DSQuery.doQuery(query, collection));            }            else if (community != null)            {                logInfo = "community_id=" + community.getID() + ",";                request.setAttribute("community", community);                // Get the collections within the community for the dropdown box                request.setAttribute("collection.array",                    community.getCollections());                handles = DSQuery.getItemResults(DSQuery.doQuery(query, community));            }            else            {                // Get all communities for dropdown box                Community[] communities = Community.findAll(context);                request.setAttribute("community.array", communities);                handles = DSQuery.getItemResults(DSQuery.doQuery(query));            }            // Make Item objects from the handles            items = new Item[handles.size()];//            ItemIDs = new String[itemHandles.size()];            for (int i = 0; i < handles.size(); i++)            {                String myhandle = (String) handles.get(i);                                Object o = HandleManager.resolveToObject(context, myhandle);                                // for now all returned objects are items                items[i] = (Item)o;                if (items[i] == null)                {                    throw new SQLException("Query \"" + query +                        "\" returned unresolvable handle: " + myhandle);                }//                handles[i] = HandleManager.findHandle(context, items[i]);            }            // Log            log.info(LogManager.getHeader(context,                "search",                logInfo + "query=\"" + query + "\",results=" + items.length));        }        catch (ParseException pe)        {            /*             * A parse exception means there were some weird characters in             * the query we couldn't resolve.  We'll pretend the search went             * OK but with no results for the user, but log the error, since             * this shouldn't really happen.             */            log.warn(LogManager.getHeader(context,                "search_exception",                logInfo + "query=\"" + query + "\""),                pe);            // Empty results            items   = new Item[0];            handles = (List)new ArrayList();        }	catch (TokenMgrError tme)	{            // Similar to parse exception            log.warn(LogManager.getHeader(context,                "search_exception",                logInfo + "query=\"" + query + "\""),                tme);            // Empty results            items   = new Item[0];            handles = (List)new ArrayList();	}    String [] handlesarray = new String[handles.size()];    handlesarray = (String [])handles.toArray(handlesarray);        // Pass the results to the display JSP        request.setAttribute("items", items);        request.setAttribute("handles", handlesarray);        // And the original query string        request.setAttribute("query", query);        JSPManager.showJSP(request, response, "/search/results.jsp");    }