import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.sql.*; public class baas extends HttpServlet{ public void doPost(HttpServletRequest kysimus, HttpServletResponse vastus) throws IOException, ServletException{ doGet(kysimus, vastus); } public void doGet(HttpServletRequest kysimus, HttpServletResponse vastus) throws IOException, ServletException{ vastus.setContentType("text/html"); PrintWriter valja=new PrintWriter(vastus.getWriter()); String t1 =kysimus.getParameter("textfield1"); String t2 =kysimus.getParameter("textfield2"); String t3 =kysimus.getParameter("textfield3"); String t4 =kysimus.getParameter("textfield4"); String t5 =kysimus.getParameter("textfield5"); System.out.println("1: "+t1+" "+t2+" "+t3+" "+t4+" "+t5); try{ if (t1 !=null && t2 !=null && t3 !=null && t4 !=null && t5 !=null ){ System.out.println("lisab"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection cn=DriverManager.getConnection("jdbc:odbc:tunniplaan", "", ""); Statement st=cn.createStatement(); String lause="INSERT INTO plaan (Kuupäev, Kellaaeg, [Õppeaine nimetus], Õppejõud, Ruum)"+ "values ('"+t1+"','"+t2+"','"+t3+"','"+t4+"','"+t5+"');"; st.executeUpdate(lause); cn.close(); Connection cn1=DriverManager.getConnection("jdbc:odbc:tunniplaan", "", ""); Statement st1=cn1.createStatement(); ResultSet rs1=st1.executeQuery("SELECT * FROM plaan;"); while(rs1.next()){ valja.println(rs1.getString("Kuupäev")+" "+rs1.getTime("Kellaaeg")+" " +rs1.getString("Õppeaine nimetus")+" "+rs1.getString("Õppejõud")+" "+rs1.getString("Ruum")+"
"); } cn.close(); } }catch(Exception e){e.printStackTrace(valja);} valja.println("\n"); valja.println("
\n"); valja.println("Lisamine \n" ); valja.println("\n"+ " \n"+ " \n"+ " \n"+ " \n"+ " \n" + " \n"+ " \n"+ " \n"+ " \n"+ " \n"+ " \n"+ " \n"+ " \n" + " \n"+ " \n"+ " \n"+ " \n" + " \n"+ " \n"+ " \n"+ " \n"+ " \n"+ " \n"+ " \n"+ "
Kuupäev \n"+ " \n"+ "
Kellaaeg\n" + " \n"+ "
Õppeaine nimetus\n" + " \n"+ "
Õppejõud\n" + " \n"+ "
Ruum\n" + " \n"+ "
 \n"+ " \n"+ "
\n
" ); valja.println("\n"); } }