Servlet编写登录界面
package com.mhb;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class LoginServlet extends HttpServlet {
public void init() throws ServletException {
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=gb2312");
response.setHeader("content-type","text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.print("<html><br />");
out.print("<body><br />");
out.print("<b>输入用户名和密码</b><br />");
out.print("<form action='' method='get'><br />");
out.print("<table><tr><td align='right'>用户名:</td>");
out.print("<td><input type='text' name='username'></td>");
out.print("<tr><td align='right'>密码:</td>");
out.print("<td><input type='password' name='password'></td>");
out.print("<tr><td conspan='2'><input type='submit' value='提交'>" +
"<input type='reset' value='重置'></td></tr></table>");
out.print("</form><br />");
out.print("</body><br />");
out.print("</html><br />");
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
public void destroy() {
super.destroy();
}
}
浏览器显示