troubleshooting Question

if --else

Avatar of mismicky
mismicky asked on
Java
5 Comments2 Solutions259 ViewsLast Modified:
i input null or input value .
it is alway output run1.
why?


<%@ page language="java" contentType="text/html;charset=Big5" %>
<%@ page import="java.sql.*" %>
<html>
<head>
<title>(select)</title>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
</head>
<body bgcolor="#FFFFFF">
<p>
</p>
  <%
     
    String sql;
    String MICE_ID = request.getParameter("MICE_ID");
    String SEX = request.getParameter("SEX");
    String STRAIN1= request.getParameter("STRAIN1");
    String STRAIN2= request.getParameter("STRAIN2");
   out.println("MICE_ID="+MICE_ID);
if (MICE_ID !=null){
   out.println("run1");
         sql="SELECT * FROM inputmice  WHERE MICE_ID='"+MICE_ID+"'";
     }else {
     out.println("2");
          sql="SELECT * FROM inputmice where SEX='"+SEX+"' ";
      }

 
    Class.forName("org.gjt.mm.mysql.Driver");
    Connection con = DriverManager.getConnection
                ("jdbc:mysql://192.168.29.21:3306/mice","root","micky0328");
    java.sql.Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery(sql);
 
%>
<FROM METHOD="POST" ACTION="">
<table width="100%" border="1">
  <tr bgcolor="#9966FF">
    <td>MICE_ID</td>
    <td>STRAIN</td>
    <td>DOB</td>
    <td>CROSS</td>
    <td>SEX</td>
    <td>FatherID</td>
    <td>MotherID</td>
    <td>EXP_DATE</td>
    <td>GATED</td>
    <td>CD4+</td>
    <td>CD8+</td>
    <td>H57</td>
    <td>CD8+CD44 HI</td>
    <td>CD8+CD44 LO</td>
    <td>CD4+CD44 HI</td>
    <td>CD4+CD44 LO</td>
    <td>DX5</td>
    <td>H57+DX5+</td>
    <td></td>
    <td></td>
  </tr>
  <tr>
<%
    while (rs.next() )
        {
%>
    <td>
      <%= rs.getString("MICE_ID")%>
    </td>
    <td>
      <%= rs.getString("STRAIN")%>
    </td>
    <td>
      <%= rs.getString("DOB")%>
    </td>
    <td>
      <%= rs.getString("CROSSES") %>
    </td>
    <td>
      <%= rs.getString("SEX")%>
    </td>
    <td>
      <%= rs.getString("FatherID")%>
    </td>
    <td>
      <%= rs.getString("MotherID")%>
    </td>
    <td>
      <%= rs.getString("EXP_DATE")%>
    </td>
    <td>
      <%= rs.getString("GATED")%>
    </td>
    <td>
      <%= rs.getString("CD4")%>
    </td>
    <td>
      <%= rs.getString("CD8")%>
    </td>
    <td>
      <%= rs.getString("H57")%>
    </td>
    <td>
      <%= rs.getString("CD8CD44HI")%>
    </td>
    <td>
      <%= rs.getString("CD8CD44LO")%>
    </td>
    <td>
      <%= rs.getString("CD4CD44HI")%>
    </td>
    <td>
      <%= rs.getString("CD4CD44LO")%>
    </td>
    <td>
      <%= rs.getString("DX5")%>
    </td>
    <td>
      <%= rs.getString("H57DX5")%>
    </td>
    <td>
    <select name="SELECT">
                <option selected>DELETE</option>
                <option>MODIFY</option>
              </select>
   </td>
   <td>
          <input type="submit" name="Submit" value="Submit">
          <input type="reset" name="reset" value="reset">
   </td>
  </tr>
<%
    }
    if (rs != null) rs.close();
    if (stmt != null) stmt.close();
    if (con != null) con.close();
    //clear connect
%>

</table>
</FROM>
<p> </p>
</body>
</html>
ASKER CERTIFIED SOLUTION
antons061400

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros