import java.sql.*; import java.util.*; import java.text.*; import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class Foorumvaataja extends HttpServlet{ public void doGet(HttpServletRequest kysimus, HttpServletResponse vastus)throws IOException, ServletException{ vastus.setContentType("text/html"); PrintWriter valja=new PrintWriter(vastus.getWriter()); try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection cn= DriverManager.getConnection("jdbc:odbc:king", "", ""); Statement st=cn.createStatement(); valja.println( "Foorum\n"+ "
"+ "
"+ "
" ); String sissekanded="SELECT count(*) as kokku FROM Foorum;"; ResultSet rs=st.executeQuery(sissekanded); rs.next(); int koik=0; koik=rs.getInt("kokku"); valja.println("Kokku on "+koik+" teadet"); koik=(koik/10); String lause="SELECT aeg,nimi,tekst FROM Foorum;"; rs=st.executeQuery(lause); String name2=""; String sonum=""; int x=0; if (kysimus.getParameter("jarg")!=null) {x=Integer.parseInt(kysimus.getParameter("jarg"));} for (int a=0; a"+ "
"+ "
"+ ""+ ""+ ""+ ""+ "
Kuupäev:"+rs.getObject("aeg")+"
Saatja:"+name2+"
Tekst:"+sonum+"
"+ "
"+ "
"+ "
"+ "
" ); } for (int kord=0; kord"+(kord+1)+""); } valja.println( "
"+ ""+ "" ); cn.close(); }catch(Exception viga){ valja.println("Probleem: "+viga); } } }