?? see.java
字號(hào):
package guestbook;import javax.servlet.*;import javax.servlet.http.*;import java.io.*;import javax.sql.DataSource;import java.sql.*;public class see extends HttpServlet { private static final String CONTENT_TYPE = "text/html; charset=GB2312"; private DataSource dataSource=null; //Initialize global variables public void init() throws ServletException { Init init=new Init(getServletContext().getRealPath("/")); dataSource=LinkDB.getDB(); if (dataSource==null) { LinkDB.setDB(init.getDriverName(),init.getDBURL(),init.getDBUser(),init.getDBPassword()); dataSource=LinkDB.getDB(); } } //Process the HTTP Get request public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType(CONTENT_TYPE); PrintWriter out = response.getWriter(); if(!Head.checkUserLogin(request)&&!Head.checkAdminLogin(request)){ out.println("<script>alert('只有登陸用戶才能查看信息');self.close();</script>"); return; } String name=request.getParameter("name"); Connection conn=null; Statement stmt=null; ResultSet rs=null; try{ conn=dataSource.getConnection(); stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); rs=stmt.executeQuery("select * from userinfo where username='"+name+"'"); if(rs.next()){ out.println("<html><head><title>"+name+"的資料</title></head>"); out.println("<body>"); out.println("用 戶 名: "+rs.getString("username").trim()+"<br>"); if(Head.checkAdminLogin(request)) out.println("密 碼: "+rs.getString("userpassword").trim()+"<br>"); out.println("真實(shí)姓名: "+rs.getString("usertruename").trim()+"<br>"); out.println("昵 稱: "+rs.getString("usernick").trim()+"<br>"); out.println("郵 箱: "+rs.getString("useremail").trim()+"<br>"); out.println(" Q Q : "+rs.getString("userqq").trim()+"<br>"); out.println("性 別: "+rs.getString("usersex").trim()+"<br>"); out.println("電 話: "+rs.getString("userphone").trim()+"<br>"); out.println("地 址: "+rs.getString("useraddress").trim()+"<br>"); out.println("愛(ài) 好: "+rs.getString("userlike").trim()+"<br>"); out.println("</body></html>"); } else{ out.println("<script>alert('用戶"+name+"不存在');self.close();</script>"); } } catch(SQLException e){ out.println(e); } finally{ try{ rs.close(); stmt.close(); conn.close(); LinkDB.shutdownDataSource(dataSource); } catch(SQLException e){ out.println(e); } } }}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -