这是Java学习的一些常用的例子
源代码在线查看: addmessage.jsp
String uid = (String)session.getAttribute("UID");
String title = request.getParameter("title");
String content = request.getParameter("content");
if ((uid==null) || (title==null) || (content==null)) {
out.print("添加留言");
out.print("");
out.print(" 添加失败,无效的系统参数!");
} else {
message.setTitle(title);
message.setContent(content);
message.setUser(uid);
messageAdmin.setRootPath(application.getRealPath("/data/"));
if (messageAdmin.add(message)) {
//添加成功,重新显示留言页面
response.sendRedirect("msg.jsp");
} else {
out.print("添加留言");
out.print("");
out.print(" MessageAmin添加失败!");
}
}
%>