for (int i = 1, j = 1; i <= countFre; ++i)
{
String frequenz = request.getParameter("frequenz" + i);
String land = request.getParameter("land" + i);
String frequenzVon =
request.getParameter("frequenzVon" + i);
String frequenzBis =
request.getParameter("frequenzBis" + i);
String kanalabstand = request.getParameter("kanalabstand" + i);
int f = Integer.parseInt(frequenz, 10);
int f_v = Integer.parseInt(frequenzVon, 10);
int f_b = Integer.parseInt(frequenzBis, 10);
if (frequenz == null ) frequenz = "";
if (land == null ) land = "";
if (frequenzVon == null) frequenzVon = "";
if (frequenzBis == null ) frequenzBis = "";
if (kanalabstand == null ) kanalabstand = "";
RandomGUID my_fre_guid = new RandomGUID();
String fre_guid = my_fre_guid.toString();
out.println("J = "+j);
%>
<%
String einheitFre = (String)request.getParameter("einheitFre"+j+"_"+i);
String einheitFreVon = (String)request.getParameter("einheitFreVon"+j+"_"+i);
String einheitFreBis = (String)request.getParameter("einheitFreBis"+j+"_"+i);
//Einheit von Frequenz####################################################
String fre1 = new String();
String fre2 = new String();
String fre3 = new String();
String fre4 = new String();
String einheit_f = new String();
if (einheitFre == null)
{
}
else if(einheitFre.equals("Hz"))
{
fre1 = "selected";
einheit_f = "Hz";
f = f;
}
else if(einheitFre.equals("kHz"))
{
fre2 = "selected";
einheit_f = "kHz";
f = f * 1000 ;
}
else if(einheitFre.equals("mHz"))
{
fre3 = "selected";
einheit_f = "mHz";
f = f * 1000000 ;
}
else if(einheitFre.equals("GHz"))
{
fre4 = "selected";
einheit_f = "GHz";
f = f * 100000000 ;
}
//Einheit von FrequenzVon####################################################
String freVon1 = new String();
String freVon2 = new String();
String freVon3 = new String();
String freVon4 = new String();
String einheit_f_von = new String();
if (einheitFre == null)
{
}
else if(einheitFre.equals("Hz"))
{
freVon1 = "selected";
einheit_f_von = "Hz";
f_v = f_v;
}
else if(einheitFre.equals("kHz"))
{
freVon2 = "selected";
einheit_f_von = "kHz";
f_v = f_v * 1000 ;
}
else if(einheitFre.equals("mHz"))
{
freVon3 = "selected";
einheit_f_von = "mHz";
f_v = f_v * 1000000 ;
}
else if(einheitFre.equals("GHz"))
{
freVon4 = "selected";
einheit_f_von = "GHz";
f_v = f_v * 100000000;
}
//Einheit von FrequenzBis####################################################
String freBis1 = new String();
String freBis2 = new String();
String freBis3 = new String();
String freBis4 = new String();
String einheit_f_bis = new String();
if (einheitFre == null)
{
}
else if(einheitFre.equals("Hz"))
{
freBis1 = "selected";
einheit_f_bis = "Hz";
f_b = f_b;
}
else if(einheitFre.equals("kHz"))
{
freBis2 = "selected";
einheit_f_bis = "kHz";
f_b = f_b * 1000 ;
}
else if(einheitFre.equals("mHz"))
{
freBis3 = "selected";
einheit_f_bis = "mHz";
f_b = f_b * 1000000 ;
}
else if(einheitFre.equals("GHz"))
{
freBis4 = "selected";
einheit_f_bis = "GHz";
f_b = f_b * 100000000 ;
}
/*out.println("f = "+ f);
out.println("f_v = "+ f_v);
out.println("f_b = "+ f_b);
*/
%>
<table width="600" border="0">
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<table>
<tr><font color="#0000FF">FrequenzBereich<%= i%>:</font></tr>
</table>
<table width="600" border="0">
<tr>
<td width="124">Frequenz: </td>
<td width="147"><%= frequenz%></td>
<td width="312"><%= einheit_f%></td>
</tr>
<tr>
<td width="124"> Land: </td>
<td width="147"><%= land%></td>
<td width="312"> </td>
</tr>
<tr>
<td width="124"> FrequenzVon: </td>
<td width="147"><%= frequenzVon%></td>
<td width="312"><%= einheit_f_von%></td>
</tr>
<tr>
<td width="124"> FrequenzBis: </td>
<td width="147"><%= frequenzBis%></td>
<td width="312"><%= einheit_f_bis%></td>
</tr>
<tr>
<td width="124">Kanalabstand: </td>
<td width="147"><%= kanalabstand%></td>
<td width="312"> </td>
</tr>
</table>
//######################################################################################
和下面的比较,他不能正确的运行单位。非常奇怪,有时间看看,那不同。下面的程序是正确的 ###
//######################################################################################
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page import = "java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.lang.*" %>
<%@ page import="de.tum.sep.*" %>
<%@ page contentType="text/html; charset=UTF-8" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>FrequenzDB</title>
</head>
<body bgcolor="#DDDDDD">
<%
String anzahlFrequenz = (String)request.getParameter("anzahlFrequenzStr");
int countFre = Integer.parseInt(anzahlFrequenz, 10);
for (int i = 1, j = 1; i <= countFre; ++i)
{
String frequenz = request.getParameter("frequenz" + i);
String land = request.getParameter("land" + i);
String frequenzVon = request.getParameter("frequenzVon" + i);
String frequenzBis = request.getParameter("frequenzBis" + i);
String kanalabstand = request.getParameter("kanalabstand" + i);
if (frequenz == null ) frequenz = "";
if (land == null ) land = "";
if (frequenzVon == null) frequenzVon = "";
if (frequenzBis == null ) frequenzBis = "";
if (kanalabstand == null ) kanalabstand = "";
int f = Integer.parseInt(frequenz, 10);
int f_v = Integer.parseInt(frequenzVon, 10);
int f_b = Integer.parseInt(frequenzBis, 10);
RandomGUID my_fre_guid = new RandomGUID();
String fre_guid = my_fre_guid.toString();
out.println("J = "+j);
%>
<table width="600" border="0">
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<table>
<tr><font color="#0000FF">FrequenzBereich<%//= i%>:</font></tr>
</table>
<%
String einheitFre = (String)request.getParameter("einheitFre"+j+"_"+i);
String einheitFreVon = (String)request.getParameter("einheitFreVon"+j+"_"+i);
String einheitFreBis = (String)request.getParameter("einheitFreBis"+j+"_"+i);
//Einheit von Frequenz ##########################################################
String fre1 = new String();
String fre2 = new String();
String fre3 = new String();
String fre4 = new String();
String einheit_f = new String();
if (einheitFre == null)
{
}else if(einheitFre.equals("Hz"))
{
fre1 = "selected";
einheit_f = "Hz";
}
else if(einheitFre.equals("kHz"))
{
fre2 = "selected";
einheit_f = "kHz";
}
else if(einheitFre.equals("mHz"))
{
fre3 = "selected";
einheit_f = "mHz";
}
else if(einheitFre.equals("GHz"))
{
fre4 = "selected";
einheit_f = "GHz";
}
//Einheit von FrequenzVon ######################################################
String freVon1 = new String();
String freVon2 = new String();
String freVon3 = new String();
String freVon4 = new String();
String einheit_f_von = new String();
if (einheitFreVon == null)
{
}else if(einheitFreVon.equals("Hz"))
{
freVon1 = "selected";
einheit_f_von = "Hz";
}
else if(einheitFreVon.equals("kHz"))
{
freVon2 = "selected";
einheit_f_von = "kHz";
}
else if(einheitFreVon.equals("mHz"))
{
freVon3 = "selected";
einheit_f_von = "mHz";
}
else if(einheitFreVon.equals("GHz"))
{
freVon4 = "selected";
einheit_f_von = "GHz";
}
//Einheit von FrequenzBis ###########################################
String freBis1 = new String();
String freBis2 = new String();
String freBis3 = new String();
String freBis4 = new String();
String einheit_f_bis = new String();
if (einheitFreBis == null)
{
}else if(einheitFreBis.equals("Hz"))
{
freBis1 = "selected";
einheit_f_bis = "Hz";
}
else if(einheitFreBis.equals("kHz"))
{
freBis2 = "selected";
einheit_f_bis = "kHz";
}
else if(einheitFreBis.equals("mHz"))
{
freBis3 = "selected";
einheit_f_bis = "mHz";
}
else if(einheitFreBis.equals("GHz"))
{
freBis4 = "selected";
einheit_f_bis = "GHz";
}
%>
<table width="600" border="0">
<tr>
<td width="124">Frequenz: </td>
<td width="147">
<input type="text" name="frequenz<%= i%>" value="<%= frequenz%>"/>
</td>
<td width="420"><%= einheit_f%></td>
</tr>
<tr>
<td width="124"> Land: </td>
<td width="147">
<input type="text" name="land<%= i %>" value="<%= land%>"/>
</td>
<td width="312"> </td>
</tr>
<tr>
<td width="124"> FrequenzVon: </td>
<td width="147">
<input type="text" name="frequenzVon<%= i %>" value="<%= frequenzVon%>"/>
</td>
<td width="420"><%= einheit_f_von%></td>
<td width="312"> </td>
</tr>
<tr>
<td width="124"> FrequenzBis: </td>
<td width="147">
<input type="text" name="frequenzBis<%= i %>" value="<%= frequenzBis%>"/>
</td>
<td width="420"><%= einheit_f_bis%></td>
<td width="312"> </td>
</tr>
<tr>
<td width="124">Kanalabstand: </td>
<td width="147">
<input type="text" name="kanalabstand<%= i %>" value="<%= kanalabstand%>"/>
</td>
<td width="312"> </td>
</tr>
</table>
<%
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection con_fre
=java.sql.DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost;1433;databaseName=RFID;","boxer",
"boxer");
Statement st_fre = con_fre.createStatement();
String sql_fre =
"INSERT INTO Frequenz (FrequenzGUID, Frequenz_in_Hz, Land,
FR_BereichVon_Hz, FR_BereichBis_Hz,
Kanalabstand_in_Hz)
VALUES ('"+fre_guid+" ','" +f+ "','"+land+ "','"+f_v+ "','" +f_b+ "','"
+kanalabstand + "')";
// st_fre.executeUpdate(sql_fre);
st_fre.close();
con_fre.close();
}catch (ClassNotFoundException e1) {
//JDBC driver class not found, print error message to the console
out.println(e1.toString());
}
catch (SQLException e2) {
// Exception
when executing java.sql related commands, print error message to the
console
out.println(e2.toString());
//out.println("Es gibt ein Ueberschreit der String");
}
catch (Exception e3) {
// other unexpected exception, print error message to the console
out.println(e3.toString());
}
%>
<%
j++;
}
%>
<table width="600" border="0">
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<table width="400">
<tr>
<td width="300"><input type="submit"
name="zurueck" value="Zurücken"
onclick="self.location.href='frequenz.jsp'" width="" maxlength="40"
/></td>
</tr>
</table>
</body>
</html>