}  out.println("<table cellpadding=6><tr><th class=\"standard\">File</th>"); if (multiFile) { out.println("<th class=\"standard\">Description</th>"); } out.println("<th class=\"standard\">Size</th class=\"standard\"><th class=\"standard\">Format</th></tr>");   if (html) { out.print("<tr><td class=\"standard\">"); out.print(primaryBitstream.getName()); if (multiFile) { out.print("</td><td class=\"standard\">"); String desc = primaryBitstream.getDescription(); out.print(desc != null ? desc : ""); } out.print("</td><td class=\"standard\">"); out.print(primaryBitstream.getSize() / 1024); out.print("Kb</td><td class=\"standard\">"); out.print(primaryBitstream.getFormatDescription()); out.print("</td><td class=\"standard\"><A TARGET=_blank HREF=\""); out.print(request.getContextPath()); out.print("/html/"); out.print(item.getHandle() + "/"); out.print(URLEncoder.encode(primaryBitstream.getName())); out.print("\">View/Open</A></td></tr>"); } else { for (int i = 0; i < bundles.length; i++) { Bitstream[] bitstreams = bundles[i].getBitstreams();  for (int k = 0; k < bitstreams.length ; k++) {  if (!bitstreams[k].getFormat().isInternal()) { out.print("<tr><td class=\"standard\">"); out.print(bitstreams[k].getName()); if (multiFile) { out.print("</td><td class=\"standard\">"); String desc = bitstreams[k].getDescription(); out.print(desc != null ? desc : ""); } out.print("</td><td class=\"standard\">"); out.print(bitstreams[k].getSize() / 1024); out.print("Kb</td><td class=\"standard\">"); out.print(bitstreams[k].getFormatDescription()); out.print("</td><td class=\"standard\"><A TARGET=_blank HREF=\""); out.print(request.getContextPath()); if (bitstreams[k].getSequenceID() > 0) { out.print("/bitstream/"); out.print(item.getHandle() + "/"); out.print(bitstreams[k].getSequenceID() + "/"); } else { out.print("/retrieve/"); out.print(bitstreams[k].getID() + "/"); } out.print(URLEncoder.encode(bitstreams[k].getName())); out.print("\">");   if(thumbs.length > 0) { String tName = bitstreams[k].getName()+".jpg"; Bitstream tb = thumbs[0].getBitstreamByName(tName);  if( tb != null ) { String myPath = request.getContextPath() + "/retrieve/" + tb.getID() + "/" + URLEncoder.encode(tb.getName());   out.print("<img src=\""+ myPath + "\" "); out.print("alt=\"" + tName + "\">"); } }  out.print("View/Open</A></td></tr>"); } } } } out.println("</table>"); }  out.println("</td></tr></table>"); }
out.println("</td></tr></table>"); }
    private void listBitstreams()        throws IOException    {        JspWriter out = pageContext.getOut();        HttpServletRequest request =            (HttpServletRequest) pageContext.getRequest();        out.print("<table align=center class=\"miscTable\"><tr>");        out.println("<td class=evenRowEvenCol><P><strong>Files in This Item:</strong></P>");        Bundle[] bundles = item.getBundles("ORIGINAL");            if (bundles.length == 0)        {            out.println("<P>There are no files associated with this item.</P>");        }        else        {   	    // if item contains multiple non-license bundles, display bitstream description	    boolean multiFile = (bundles.length > 2);            boolean html = false;	    Bitstream primaryBitstream = null;	    Bundle[] bunds = item.getBundles("ORIGINAL");            Bundle[] thumbs= item.getBundles("THUMBNAIL");	    // check if primary bitstream is html	    if (bunds[0] != null)	    {		Bitstream[] bits = bunds[0].getBitstreams();		for (int i = 0; i < bits.length && !html; i++)		{		    if (bits[i].getID() == bunds[0].getPrimaryBitstreamID())		    {			html = bits[i].getFormat().getMIMEType().equals("text/html");			primaryBitstream = bits[i];		    }		}	    }	    out.println("<table cellpadding=6><tr><th class=\"standard\">File</th>");	    if (multiFile)	    {		out.println("<th class=\"standard\">Description</th>");	    }	    out.println("<th class=\"standard\">Size</th class=\"standard\"><th class=\"standard\">Format</th></tr>");            // if primary bitstream is html, display a link for only that one to HTMLServlet            if (html)	    {		out.print("<tr><td class=\"standard\">");		out.print(primaryBitstream.getName());		if (multiFile)		{		    out.print("</td><td class=\"standard\">");		    String desc = primaryBitstream.getDescription();		    out.print(desc != null ? desc : "");		}		out.print("</td><td class=\"standard\">");		out.print(primaryBitstream.getSize() / 1024);		out.print("Kb</td><td class=\"standard\">");		out.print(primaryBitstream.getFormatDescription());		out.print("</td><td class=\"standard\"><A TARGET=_blank HREF=\"");		out.print(request.getContextPath());		out.print("/html/");		out.print(item.getHandle() + "/");		out.print(URLEncoder.encode(primaryBitstream.getName()));		out.print("\">View/Open</A></td></tr>");	    }	    else	    {	    		for (int i = 0; i < bundles.length; i++)		{		    Bitstream[] bitstreams = bundles[i].getBitstreams();					    for (int k = 0; k < bitstreams.length ; k++)		    {			// Skip internal types			if (!bitstreams[k].getFormat().isInternal())			{			    out.print("<tr><td class=\"standard\">");			    out.print(bitstreams[k].getName());			    if (multiFile)			    {				out.print("</td><td class=\"standard\">");				String desc = bitstreams[k].getDescription();				out.print(desc != null ? desc : "");			    }			    out.print("</td><td class=\"standard\">");			    out.print(bitstreams[k].getSize() / 1024);			    out.print("Kb</td><td class=\"standard\">");			    out.print(bitstreams[k].getFormatDescription());			    out.print("</td><td class=\"standard\"><A TARGET=_blank HREF=\"");			    out.print(request.getContextPath());			    if (bitstreams[k].getSequenceID() > 0)			    {				out.print("/bitstream/");				out.print(item.getHandle() + "/");				out.print(bitstreams[k].getSequenceID() + "/");			    }			    else			    {				out.print("/retrieve/");				out.print(bitstreams[k].getID() + "/");			    }			    out.print(URLEncoder.encode(bitstreams[k].getName()));			    out.print("\">");                                                        // is there a thumbnail bundle?                            if(thumbs.length > 0)                            {                                String tName = bitstreams[k].getName()+".jpg";                                Bitstream tb = thumbs[0].getBitstreamByName(tName);                                                            if( tb != null )                                {                                    String myPath = request.getContextPath() + "/retrieve/" + tb.getID()                                        + "/" + URLEncoder.encode(tb.getName());                                                                    //out.print(myPath);                                        out.print("<img src=\""+ myPath + "\" ");                                    out.print("alt=\"" + tName + "\">");                                }                            }                                                        out.print("View/Open</A></td></tr>");			}		    }		}	    }            out.println("</table>");        }                out.println("</td></tr></table>");    }