import java.io.*; import java.util.Enumeration; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; import java.net.*; public class testservlet extends HttpServlet{ Connection theConnection; private ServletConfig config; public void init(ServletConfig config) throws ServletException{ this.config=config; } public void service (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { HttpSession session = req.getSession(true); res.setContentType("text/html"); PrintWriter out = res.getWriter(); out.println("Liste over ansatte i SFI"); out.println(""); out.println(""); out.println("

List of E-mail addresses.

"); out.println("

"); out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); try{ //Loading Sun's JDBC ODBC Driver Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //Class.forName("postgresql.Driver"); //Connect to emaildb Data source theConnection = DriverManager.getConnection("jdbc:odbc:pg"); Statement theStatement=theConnection.createStatement(); ResultSet theResult=theStatement.executeQuery("select * from pstillinger where OnlineFra <= current.timestamp and OnlineTil >= current.timestamp"); //Select all records from emaillists table. //Fetch all the records and print in table while(theResult.next()){ out.println(); out.println(""); out.println(""); out.println(""); out.println(""); String s=theResult.getString(5); out.println(""); out.println(""); } theResult.close();//Close the result set theStatement.close();//Close statement theConnection.close(); //Close database Connection }catch(Exception e){ out.println(e.getMessage());//Print trapped error. } out.println("
kolonne1kolonne2kolonne3
" + theResult.getString(2) + "" + theResult.getString(3) + "" + theResult.getString(4) + "" + s + ">

"); out.println("

 

"); } public void destroy(){ } }