我是 servlet 的新手。我有一个 servlet,我更新其中的数据库。单击提交按钮后,我想显示一条消息,告知更新是否成功。为此,我打算放置一个标签,但标签标签没有值、可见等属性。我该怎么做?这是我的servlet代码:
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//System.out.println("editservlet");
try
{
connect();
int result=-1;
PreparedStatement checkDB = (PreparedStatement) con.prepareStatement(
"UPDATE users set username=?,password=?,name=?,surname=?,phone=?,address=?," +
"email=? where username=?");
checkDB.setString(8,request.getParameter("tUserName"));
checkDB.setString(1,request.getParameter("tUserName"));
checkDB.setString(2,request.getParameter("tPassword"));
checkDB.setString(3,request.getParameter("tName"));
checkDB.setString(4,request.getParameter("tSurName"));
checkDB.setString(5,request.getParameter("tPhone"));
checkDB.setString(6,request.getParameter("tAddress"));
checkDB.setString(7,request.getParameter("tEmail"));
result= checkDB.executeUpdate();
if(result>0)
//SHOW THE MESSAGE THAT TELLS UPDATE SUCCESFUL
}
catch(Exception e)
{
e.printStackTrace();
//SHOW THE MESSAGE THAT UPDATE UNSUCCESFUL
}
}
谁能帮我这个?谢谢