?? checkname.java
字號:
package com.xj.serv;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.xj.bean.DB;
public class checkName extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session = request.getSession();
String u=request.getParameter("UserName");
u=new String(u.getBytes("iso-8859-1"),"gb2312");
u=u.toLowerCase();
DB db = new DB();
try {
db.openConn();
String s= db.checkUser(u);
if(s.equals("")){
session.setAttribute("empty", 0);
//將當(dāng)前用戶明存起來,以便跳轉(zhuǎn)回注冊頁后調(diào)用
session.setAttribute("thisName", u);
}else{
session.setAttribute("empty", 1);
session.setAttribute("thisName", "");
}
} catch (ClassNotFoundException e) {
System.out.println(e.getMessage());
} catch (SQLException e) {
System.out.println(e.getMessage());
}finally{
try {
db.closeRsAll();
response.sendRedirect("reg.jsp");
} catch (SQLException e) {
System.out.println(e.getMessage());
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -