import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.sql.*; public class otsing extends HttpServlet{ public void doPost(HttpServletRequest paring, HttpServletResponse vastus) throws IOException, ServletException{ doGet(paring, vastus); } public void doGet(HttpServletRequest paring, HttpServletResponse vastus) throws IOException, ServletException{ vastus.setContentType("text/html"); PrintWriter valja=new PrintWriter(vastus.getWriter()); String otsing1 =paring.getParameter("t1"); String otsing2 =paring.getParameter("t2"); String otsing3 =paring.getParameter("t3"); try{ if (otsing1 !=null && otsing2 !=null && otsing3 !=null){ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection cn=DriverManager.getConnection("jdbc:odbc:java", "", ""); Statement st=cn.createStatement(); String lause="SELECT * FROM klient WHERE Perenimi LIKE '" +otsing1+ "%' AND Eesnimi LIKE '" +otsing2+ "%' AND Tanav LIKE '" +otsing3+"%';"; ResultSet rs=st.executeQuery(lause); valja.println( "Otsingu tulemus"+ ""+ " "+ " "+ " "+ " "+ " "+ " "+ " " ); while (rs.next()){ valja.println("\n"+ "\n"+ "\n"+ "\n"+ "" ); } valja.println("
PerenimiEesnimiTänavMajaKorter
"+rs.getString("Perenimi")+""+rs.getString("Eesnimi")+""+rs.getString("Tanav")+""+rs.getString("Maja")+""+rs.getString("Korter")+"
\n"); cn.close(); } }catch(Exception e){e.printStackTrace(valja);} //kuvatakse kõik veateated valja.println("\n"); valja.println("
\n"); valja.println("

Otsing

\n" ); valja.println("\n"+ " \n"+ " \n"+ " \n"+ " \n"+ " \n" + " \n"+ " \n"+ " \n"+ " \n"+ " \n"+ " \n"+ " \n"+ " \n"+ " \n"+ " \n"+ " \n"+ "
Perekonnanimi \n"+ " \n"+ "
Eesnimi\n" + " \n"+ "
Tänav\n" + " \n"+ "
 \n"+ " \n"+ "
\n
" ); valja.println("\n"); } }