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"+ "
Perenimi | "+ "Eesnimi | "+ "Tänav | "+ "Maja | "+ "Korter | "+ "
"+rs.getString("Perenimi")+" | \n"+ ""+rs.getString("Eesnimi")+" | \n"+ ""+rs.getString("Tanav")+" | \n"+ ""+rs.getString("Maja")+" | \n"+ ""+rs.getString("Korter")+" |