主题:急救!
main.jsp
<body>
<jsp:useBean id="Use" scope="page" class="zouqingming.DBManager" />
<p>
搜索新闻
</p>
<form name="form1" method="post" action="">
<p>输入关键字
<input name="text" type="text" maxlength="10">
<input type="submit" name="Submit" value="搜索">
</p>
<p> </p>
<% request.setCharacterEncoding("gb2312"); %>
<%
String texts = request.getParameter("text");
//String page;
if(texts!=null){
try{
ResultSet rs = Use.query("select title from news where title='"+texts+"';");
while(rs.next()){
%>
<a href="view.jsp?doc=<%=rs.getString("title")%>"><%=rs.getString("title")%></a>
<%
}
}
catch(Exception e){}
}
%>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</form>
<p>
</p>
</body>
view.jsp
<body>
<jsp:useBean id="Use" scope="page" class="zouqingming.DBManager" />
<% request.setCharacterEncoding("gb2312"); %>
<%
String sql = request.getParameter("doc");
//String sql = rs.getString("title");
try{
ResultSet rs = Use.query("select text from news where title=sql;");
while(rs.next()){
out.println(sql);
out.print(rs.getString("text"));
}
}
catch(Exception e){}
%>
</body>
为什么实现不了我想要的连接功能?
<body>
<jsp:useBean id="Use" scope="page" class="zouqingming.DBManager" />
<p>
搜索新闻
</p>
<form name="form1" method="post" action="">
<p>输入关键字
<input name="text" type="text" maxlength="10">
<input type="submit" name="Submit" value="搜索">
</p>
<p> </p>
<% request.setCharacterEncoding("gb2312"); %>
<%
String texts = request.getParameter("text");
//String page;
if(texts!=null){
try{
ResultSet rs = Use.query("select title from news where title='"+texts+"';");
while(rs.next()){
%>
<a href="view.jsp?doc=<%=rs.getString("title")%>"><%=rs.getString("title")%></a>
<%
}
}
catch(Exception e){}
}
%>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</form>
<p>
</p>
</body>
view.jsp
<body>
<jsp:useBean id="Use" scope="page" class="zouqingming.DBManager" />
<% request.setCharacterEncoding("gb2312"); %>
<%
String sql = request.getParameter("doc");
//String sql = rs.getString("title");
try{
ResultSet rs = Use.query("select text from news where title=sql;");
while(rs.next()){
out.println(sql);
out.print(rs.getString("text"));
}
}
catch(Exception e){}
%>
</body>
为什么实现不了我想要的连接功能?