俺初学jsp,请问一个菜问题,请帮忙啊,急,送分100
news.jsp(记录的列表显示)中用out.print("<a href='newscontext.jsp?id="+id+"' onClick='return newwin(this.href);'><font color='red' size='2'>"+title+"</font></a></td>");来链接每一条记录的具体显示
然后同newscontext.jsp来显示具体的每一条记录:
String id=request.getParameter("id");
ResultSet rs=newsBean.executeQuery("select * from news where id="+id);
结果newscontext.jsp报错的头部信息是:Error: 500
Location: /mynews/newscontext.jsp
Internal Servlet Error:
org.apache.jasper.compiler.ParseException: C:\jakarta-tomcat-3.2.3\webapps\ROOT\mynews\newscontext.jsp(6,4) Invalid directive
其中:id为主键
news.jsp:<html>
<head>
<%@ page contentType="text/html;charset=gb2312"%>
<title>新闻摘要 </title>
</head>
<body>
<%@ page language="java" import="java.sql.*"%>
<jsp:useBean id="newsBean" scope="page" class="news.news"/>
<%
ResultSet rs=newsBean.executeQuery("select top 5 * from news order by id desc");
String title;
String id;
Date time;
%>
<table width="70%" border="1" cellspaing="0" cellpading="5" align="center">
<%
while (rs.next()){
title=rs.getString("title");
time=rs.getDate("time");
id=rs.getString("id");
out.print("<tr>");
out.print("<td width='80%'>");
out.print("<a href='newscontext.jsp?id="+id+"' onClick='return newwin(this.href);'><font color='red' size='2'>"+title+"</font></a></td>");
out.print("<td><font color='blue' size='1'><i>"+time+"</i></font></td>");
out.print("</tr>");
}
rs.close();
%>
</table>
</body>
</html>
newscontext.jsp:
<html>
<head>
<%@ page contentType="text/html;charset=gb2312"%>
<title>新闻记录显示</title>
</head>
<body>
<%@ language="java" import="java.sql.*"%>
<jsp:useBean id="newsBean" scope="page" class="news.news"/>
<%
String id=request.getParameter("id");
ResultSet rs=newsBean.executeQuery("select * from news where id="+id);
String title;
String id;
Date time;
String context;
%>
<table width="70%" border="1" cellspaing="0" cellpading="3" align="center">
<%
while (rs.next()){
title=rs.getString("title");
context=rs.getString("context");
time=rs.getDate("time");
out.print("<tr>");
out.print("<td><font color='blue' size='1'>"+title+"</font></td>");
out.print("</tr>");
out.print("<tr>");
out.print("<td><font color='blue' size='1'>"+time+"</font></td>");
out.print("</tr>");
out.print("<tr>");
out.print("<td><font color='blue' size='1'>"+context+"</font></td>");
out.print("</tr>");
}
rs.close();
%>
</table>
</body>
</html>
其中:id为主键,title为标题,context为记录的具体内容。