📄 viewuserinfo.java
字号:
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class viewuserinfo extends HttpServlet
{
public viewuserinfo()
{
}
public void init(ServletConfig servletconfig)
throws ServletException
{
super.init(servletconfig);
try
{
System.out.println("inside init");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:ecare","ecare","ecare");
// Class.forName("oracle.jdbc.driver.OracleDriver");
// con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:india","ecare","ecare");
st=con.createStatement();
System.out.println("statement is created");
}
catch(Exception exception)
{
System.out.println(exception);
}
}
public void service(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
throws ServletException, IOException
{
PrintWriter printwriter = httpservletresponse.getWriter();
httpservletresponse.setContentType("text/html");
javax.servlet.http.HttpSession httpsession = httpservletrequest.getSession(true);
try
{
String s = httpservletrequest.getParameter("cn");
printwriter.println("<html>");
printwriter.println("<head>");
printwriter.println("<style>");
printwriter.println("a{ Text-Decoration:none;}");
printwriter.println("</style>");
printwriter.println("</head>");
printwriter.println("<body>");
printwriter.println("<form > ");
printwriter.println("<P align=center><FONT size=5><STRONG ");
printwriter.println("style='COLOR: forestgreen'><U>HD User Info</U></STRONG></FONT></P>");
printwriter.println("<P align=center> </P>");
printwriter.println("<P align=center>");
printwriter.println("<TABLE border=0 cellPadding=1 cellSpacing=1 style='HEIGHT: 130px; WIDTH: 431px'");
printwriter.println("width=75%>");
printwriter.println("<TR>");
printwriter.println("<TD><strong> User ID</strong></TD></TR>");
String s1;
for(rs = st.executeQuery("select user_id from userinfo where companyname='" + s + "'"); rs.next(); printwriter.println("<TD> " + s1 + " </TD></TR>"))
{
s1 = rs.getString(1);
printwriter.println("<TR>");
}
printwriter.println("<TR>");
printwriter.println("<TD></TD></TR>");
printwriter.println("<TD> <a href='./superuserview.html' target='_parent'><strong> Go Back</strong></a></TD></TR>");
}
catch(Exception exception)
{
System.out.println(exception);
}
}
Connection con;
Statement st;
ResultSet rs;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -