Hi i need to remove duplicate items (as if more than one item which is movie of the same title is added, the title will appear only once with the with correct quantity also displayed.

so this is the code of java Servlet i have done so far

Java Code:
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();

   out.println("<html>");
    out.println("<head><title>HiddenFormFieldsServlet</title></head>");
    out.println("<body>");

    out.println("<form method=\"POST\" action=\"cart\">");
    out.println("<select name=\"movies\" size =7 multiple>");
    out.println("<option selected>Ned Kelly</option>");
    out.println("<option>Chicago</option>");
    out.println("<option>Gangs of New York</option>");
    out.println("<option>Hours</option>");
    out.println("<option>Matrix</option>");
    out.println("<option>I Robot</option>");
    out.println("<option>Once upon a time in Mexico</option>");
    out.println("<option>Jeepers Creepers 2</option>");
    out.println("<option>American Pie 2</option>");
    out.println("<option>Spider Man 2</option>");
    out.println("</select><BR>");

    String items[] = request.getParameterValues("movies");

    //
    // Convert it to list as we need the list object to create a
    // set object. A set is a collection object that cannot have
    // a duplicate values, so by converting the array to a set
    // the duplicate value will be removed.
    //
    List<String> list = Arrays.asList(items);
    Set<String> set = new HashSet<String>(list);

    out.print("Remove duplicate result: ");

    //
    // Create an array to convert the Set back to array.
    // The Set.toArray() method copy the value in the set to the
    // defined array.
    //
    String[] result = new String[set.size()];
    set.toArray(result);
    for (String s : result) {
        out.print(s + ", ");
    }


    if(items != null) {
        for(int i=0; i<items.length; i++) {
             out.println("<INPUT TYPE=hidden name=\"movies\" VALUE=\"" +
             items[i] + "\">");
        }
    }

    out.println("<p><input type=\"submit\" value=\"Add To Cart\" name=\"B1\"></p>");
    out.println("</form>");
    out.println("</body></html>");

    out.close();
the result the output should have a error because i have no idea how to output the result in one particular item.