Hvorfor får jeg siden kan ikke vises
package mypackage;import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class resultater extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
show(response.getWriter());
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/hsf");
Statement stmt = con.createStatement();
String name = request.getParameter("name");
String klasse = request.getParameter("class");
String point = request.getParameter("point");
stmt.executeUpdate("INSERT INTO resultat(name,class,point) " +
"VALUES ('" + name + "','" + klasse + "','" + point + "')");
stmt.close();
con.close();
}
catch (ClassNotFoundException e) {
throw new ServletException(e.getMessage());
}
catch (SQLException e) {
throw new ServletException(e.getMessage());
}
show(response.getWriter());
}
private void show(PrintWriter out) throws ServletException
{
out.println("<!doctype html public '-//w3c/dtd HTML 4.01 Transitional//en'>");
out.println("<html>");
out.println("<head>");
out.println("<title>Resultater</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Resultater</h1>");
out.println("<h2>Eksisterende resultater:</h2>");
out.println("<table border>");
out.println("<tr>");
out.println("<th>Navn</th>");
out.println("<th>Klasse</th>");
out.println("<th>Point</th>");
out.println("</tr>");
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/hsf");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT name,class,point FROM resultat");
while(rs.next()) {
out.println("<tr>");
out.println("<td>" + rs.getString("name") + "</td>");
out.println("<td>" + rs.getString("klasse") + "</td>");
out.println("<td>" + rs.getInt("point") + "</td>");
out.println("</tr>");
}
rs.close();
stmt.close();
con.close();
} catch (ClassNotFoundException e) {
throw new ServletException(e.getMessage()); }
catch (SQLException e) {
throw new ServletException(e.getMessage()); }
out.println("</table>");
out.println("<h2>Tilføj resultater:</h2>");
out.println("<form method='post' action='resultater'>");
out.println("Navn: <input type='text' name='name' size='40'>");
out.println("<br>");
out.println("Klasse: <input type='text' name='klasse' size='20'>");
out.println("<br>");
out.println("Point: <input type='text' name='point' size='40'>");
out.println("<br>");
out.println("<input type='submit' value='Tilføj'>");
out.println("</form>");
out.println("</body>");
out.println("</html>");
}
}