这是我的jsp方法。在这个我想用out.println,但是eclipse显示错误无法解决掉。我已经读过jsp方法隐含可用了。那它为什么不起作用?
public void getTest(HttpSession session)
{
String username = (String)session.getAttribute("email");
try{
Class.forName("com.mysql.jdbc.Driver");
//creating connection with the database
Connection con=DriverManager.getConnection
("jdbc:mysql://localhost:3306/quizilla","root","manish123");
String query="select test_name, number, max_marks from test_table where email='"+username+"'";
PreparedStatement ps =con.prepareStatement(query);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
String test_name = rs.getString("test_name");
int number= rs.getInt("number");
int max_marks=rs.getInt("max_marks");
String div="<div style='height:8%;width:74.8%;float:right; border:1px solid #000000'>";
out.println(div);
}
}
catch(Exception e)
{}
}
答案 0 :(得分:0)
使用jsp声明定义方法时,它无法访问仅out
方法可用的_jspservice()
变量。您不能在任何其他方法中使用它,除非您将其传递给方法如下。
public void getTest(HttpSession session, OutputStream out)