servlet中按钮怎么用
这是我没弄按钮之前的代码,共有两个按钮,一个是查询,一个是清空,现在只实现了查询功能,想加入按钮,不知道怎么见?请求大家的帮助!!!
package portalest;
import
java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import
javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MessageLog extends HttpServlet {
private static final long serialVersionUID = -4431868772435676256L;
public MessageLog() {
super();
}
public void destroy() {
super.destroy();
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws
ServletException,
IOException {
Connection ct =null;
Statement sm = null;
ResultSet rs = null;
String sql = null;
try{
//解决中文乱码问题
response.setContentType("text/html;charset=gbk");
PrintWriter pw = response.getWriter();
String u = request.getParameter("uname");
String p = request.getParameter("mtype");
String b = request.getParameter("system1");
String button1 = request.getParameter("button1");
Class.forName("oracle.jdbc.driver.OracleDriver");
ct = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ORCL", "guodandan", "1");
sm = ct.createStatement();
if(u==null&&p==null&&b==null) {
sql = "select * from message_log";
}
else {
u = new String(u.getBytes("ISO-8859-1"),"GBK");
p = new String(p.getBytes("ISO-8859-1"),"GBK");
b = new String(b.getBytes("ISO-8859-1"),"GBK");
sql = "select * from message_log where uname='" + u +"' and mtype='"+p+"' and system1='"+b+"'";
System.out.println(sql);
}
rs = sm.executeQuery(sql);
pw.println("<HTML>");
pw.println(" <BODY>");
pw.print("<h1>消息日志监控管理</h1>");
pw.print("<h1>---------------------------------</h1>");
pw.print("<form action ='MessageLog' method = post name=f1>");
pw.print("用户:<input type = text name ='uname'>");
pw.print("消息类型:<select name = 'mtype' >");
pw.print("<option value='null' >---请选择---</option>");
pw.print("<option value='业务待办' >业务待办</option>");
pw.print("<option value='业务提醒' >业务提醒</option>");
pw.print("<option value='通知公告' >通知公告</option>");
pw.print("</select>");
pw.print("业务系统:<select name = 'system1'>");
pw.print("<option value='null' >---请选择---</option>");
pw.print("<option value='股权系统' >股权系统</option>");
pw.print("<option value='项目系统' >项目系统</option>");