getmedia.jsp

来自「《J2EE企业级应用开发》一书的配套源代码」· JSP 代码 · 共 50 行

JSP
50
字号
<%@ page import="java.io.IOException,java.util.*,javax.naming.*,javax.servlet.*,
javax.servlet.http.*,java.rmi.*,javax.rmi.PortableRemoteObject,javax.ejb.*,com.j2eeapp.cdstore.storage.*,com.j2eeapp.cdstore.vo.*,com.j2eeapp.cdstore.util.*" %>
<%
	InitialContext ctx=new InitialContext();
   String productId="product_Demo_11";
   
   try
   {
   	 

ProductLocalHome productHome=(ProductLocalHome)new InitialContext().lookup(JNDINames.PRODUCT);
   	   ProductLocal productLocal=productHome.findByPrimaryKey(productId);
   	   Product productVO=new Product(productLocal.getProductId(),productLocal.getCategory().getCateId(),
   	   			productLocal.getName(),productLocal.getDescription(),(Collection)productLocal.getMediaList());
   	   			 Collection medias =productVO.getMedia();
 if(medias!=null)out.println("mediasnotnull");
 out.println(medias.size());
Iterator it=medias.iterator();
%>
<table border="0" cellspacing="0" cellpadding="2" width="500">

   <tr>
   <th background="images/titlebar_stretch.gif" valign="top" class="title" align="left">曲名</th>
   <th background="images/titlebar_stretch.gif" align="right" valign="center" class="title">描述  </th>
   <th background="images/titlebar_stretch.gif" align="right" valign="center" class="title">时间 </th>
      <th background="images/titlebar_stretch.gif" align="right" valign="center" class="title">出品人 </th>
  </tr>
<% while(it.hasNext())
  {  
     Media pr=(Media)it.next();
  %>  
  <Tr>
  <td class="heading"><%=pr.getFileName()%></td>
  <td class="heading"><%=pr.getDescription()%></td>
  <td class="heading"><%=pr.getTime()%></td>
  <td class="heading"><%=pr.getProducer()%></td>
  
  </Tr>
  <%}%>
</table>
<%
   	   	}
	catch(NamingException e)
	{
	    e.printStackTrace();
	 }
	 

%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?