在瀏覽器中顯示一個特定的錯誤,我做了一個javabean類和error.jsp。問題是這個我想在error.jsp中顯示特定的異常。所以我做了錯誤的變量,我想誤差進來錯誤變量這樣我就可以向用戶顯示....我想通過jsp
package mypack;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class StudentBean {
int roll, marks;
String name, grade;
String error;
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
public int getMarks() {
return marks;
}
public String getName() {
return name;
}
public String getGrade() {
return grade;
}
public int getRoll() {
return roll;
}
public void setRoll(int roll) {
this.roll = roll;
}
public boolean lookup() {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:xe", "system", "oracle");
PreparedStatement pst = con
.prepareStatement("select * from student where roll=?");
pst.setInt(1, roll);
ResultSet rs = pst.executeQuery();
if (rs.next()) {
name = rs.getString(1);
roll = rs.getInt(2);
marks = rs.getInt(3);
grade = rs.getString(4);
}
} catch (Exception e) {
System.out.println("Generated Exception " + e);
error = e.getMessage();
}
return true;
}
}
你可以顯示你的jsp代碼嗎? – Bhushan 2013-03-22 04:11:25