<%@ page import="java.sql.*" %> <% Class.forName("org.gjt.mm.mysql.Driver"); Connection cn=DriverManager.getConnection( "jdbc:mysql://greeny.cs.tlu.ee/if14_jaagup_a", "if14", "ifikas2014"); Statement st=cn.createStatement(); String sorttulp="mark"; if(request.getParameter("sort")!=null && request.getParameter("sort").equals("regnr")){ sorttulp="regnr"; } ResultSet rs=st.executeQuery("SELECT regnr, mark FROM autod ORDER BY "+sorttulp); while(rs.next()){ out.println(""); } %>
Registrinumber Mark
"+rs.getString("regnr")+""+ rs.getString("mark")+"