<%@ page contentType = "text/html;charset=gb2312" %><%@page import="java.util.*" %>
<%@page import="java.io.*" %>
<%@page import="java.lang.*" %>
<%@page import="java.sql.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>娱乐新闻</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../resource/style/comm.css" rel="stylesheet" type="text/css">
<script language="javascript" src="../resource/script/calendar.js"></script>
<script language="javascript">
<!--function f_delete(values,value)
{
with(document.idform)
{
idUpdate.value = "9";
idindex.value = values;
idPage.value = value;
action = "ylxw.jsp";
submit();
}
}-->
</script>
</head><body bgcolor="#E7EBFA" leftmargin="0" topmargin="0">
<%!Connection conn  = null; %>                      
<%!Statement  stmt  = null; %>
<%!ResultSet  RS=null;%>
<%!String  sql=null;%>
<%!String[]  CName;%>
<%!String[]  sj;%>
<%!ResultSetMetaData  metaData;%><td width="600" valign="top"><form name="idform" method="get" action="http://localhost:8080/httpServlet/ylxw.jsp">
<%

String user =request.getParameter("user");%>
<input type="hidden" name="idUpdate" value="">
<%String strUpdate = request.getParameter("idUpdate");
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost/mms", "root","");
stmt = conn.createStatement();
out.println(strUpdate);
String y="1";
        if(y.equals("9"))
{
String strIndex = request.getParameter("idindex");
String strIndex1 = request.getParameter("idPage");
stmt.executeUpdate("delete from "+user);
}



%>    <td width="600" valign="top"><form name="idform" method="post">
    
    <input type="hidden" name="idUpdate" value="">
    <input type="hidden" name="idPage">
    <input type="hidden" name="idindex">
    <table width="50%" border="1">

     <tr>
<%sql="select * from "+ user;
RS = stmt.executeQuery(sql);
metaData=RS.getMetaData();
int number=metaData.getColumnCount();
CName=new String[number];%>
<tr>
<%for (int i=0;i<number;i++){
  CName[i]=metaData.getColumnLabel(i+1);%>
  <th>&nbsp;<%=CName[i]%></th>
          <% }%>
  <th>删除</th>
</tr>         
<%sj=new String[number];%>
        <tr>
<%while (RS.next()){%>
        <tr>
   <%for(int i=0;i<number;i++){
      sj[i]=RS.getString(CName[i]);%>
      <th><%=sj[i]%></th>
   <%}%>
<th>
<a href="javascript:f_delete('<%=sj[0]%>');" class="a_red">删除
</th>
        </tr>
<%}RS.close();
stmt.close();
%>
</tr>                                 
</table></td>
</form>
</body>
</html>

解决方案 »

  1.   

    我要把javascript的idUpdate.value = "9";
     传递给 jsp 的变量<input type="hidden" name="idUpdate" value="">然后再<%String strUpdate = request.getParameter("idUpdate");取的是null
      

  2.   

    没有提交!!!怎么能在request()中取出呢?
      

  3.   

    倒!~~ 这是你自己的TEST ,还是你们公司的代码?!!
    晕!!!getParameter  是获得请求中的数据,而此页面没有提交,怎么获得呢?! 还有
    既然JS里都能得到数据,JSP里也能得到了,为什么还要在当前页??
      

  4.   

    http://www.pconline.com.cn/pcedu/empolder/wz/jsp/0310/229440.html
    不知道对你有帮助么?抽时间多找找教程吧!(个人建议)