<%String sql2="Select * from product where pro_name='news' order by id desc";
int i;
ResultSet rs2 = stmt.executeQuery(sql2);
i=0;
while((i<3) && (rs2.next())){
String id=rs2.getString("id");
String title=rs2.getString("title");
String time=rs2.getString("pub_date");
%>
 <tr> 
   <td width="5%"><div align="center"><img src="image/20.jpg" width="6" height="9"></div></td>
   <td width="70%"><a href="news_more.jsp?id=<%=id%>" class="2"><%=title%></a></td>
   <td width="25%" style="font-size=12px">[<%=time%>]</td> 
 </tr>
 <%  i++;
     }
     rs2.close();
  %>
我的一段代码,有几个问题,请教大家。
1、用这句String time=rs2.getString("pub_date");获得的日期是这种样子:2005-04-13 00:00:00.0但是,我想让他2005-04-13这样显示,我用的是 sql server的数据库,数据库中的日期字段是small datetime型的。四位的长度。
2、还一个问题就是如何释放rs   
3、还有jsp中的字符串替换函数和字符串截取函数是什么,以及他的用法。
下面是news_more.jsp的内容:
<%
String id1=request.getParameter("id");
if(id1==""){id1="0";}
int id2=Integer.parseInt(id1);
%>
<%
  String sql1="select * from product where id="+id2;
  ResultSet rs1 = stmt.executeQuery(sql1);
  String title=rs1.getString("title");
  String img=rs1.getString("img");
  String pub_date=rs1.getString("pub_date");
  String content=rs1.getString("content");
 %>
4、看看上面两段代码,为什么会有错误,好象是SQL语句的错误。
下面帖出错误:java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid
operation for the current cursor position.
精确截取字符串 
来源:   作者: String getLimitString(String src,int len){
   StringBuffer sb = new StringBuffer();
   char[] c = src.toCharArray();
   for(int x=0;x<c.length;x++){
     if(sb.toString().getBytes().length < len)
       sb.append(c[x]);
   }
   return src;
}在JSP中定义函数 
来源:   作者: <%@page contentType="text/html;charset=GBK"%>
<%!
String hello(){
  return "这是在JSP中定义函数的测试";
}
%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>在JSP中定义函数</title>
</head>
<body>
<%=hello()%>
</body>
</html>