/*
 * Generated by the Jasper component of Apache Tomcat
 * Version: Apache Tomcat/7.0.56
 * Generated at: 2018-02-26 08:54:54 UTC
 * Note: The last modified time of this file was set to
 *       the last modified time of the source file after
 *       generation to assist with modification tracking.
 */
package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import paketBMIDB.Person;
import paketBMIDB.Datenbankzugriff;

public final class bmiberechnungDB_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static final javax.servlet.jsp.JspFactory _jspxFactory =
          javax.servlet.jsp.JspFactory.getDefaultFactory();

  private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants;

  private javax.el.ExpressionFactory _el_expressionfactory;
  private org.apache.tomcat.InstanceManager _jsp_instancemanager;

  public java.util.Map<java.lang.String,java.lang.Long> getDependants() {
    return _jspx_dependants;
  }

  public void _jspInit() {
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
    _jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig());
  }

  public void _jspDestroy() {
  }

  public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
        throws java.io.IOException, javax.servlet.ServletException {

    final javax.servlet.jsp.PageContext pageContext;
    javax.servlet.http.HttpSession session = null;
    final javax.servlet.ServletContext application;
    final javax.servlet.ServletConfig config;
    javax.servlet.jsp.JspWriter out = null;
    final java.lang.Object page = this;
    javax.servlet.jsp.JspWriter _jspx_out = null;
    javax.servlet.jsp.PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\r\n");
      out.write("\r\n");
      out.write("<html>\r\n");
      out.write("<head>\r\n");
      out.write("<title>BMI-Rechner</title>\r\n");
      out.write("</head>\r\n");
      out.write("<body>\r\n");
      out.write("<h1>BMI-Rechner </h1>\r\n");
      out.write("<h2>Ihr Body-Mass-Index beträgt:</h2>\r\n");

      String eingabeGewicht;
      String eingabeGroesse;
	  String eingabeGeschlecht;
	  String eingabeName;
	  String eingabeJahre;
      double gewicht;
      double groesse;
	  int jahre;
	  	  
	  eingabeGewicht = request.getParameter("tfGewicht");
      eingabeGroesse = request.getParameter("tfGroesse");
	  eingabeGeschlecht = request.getParameter("rbGeschlecht");
	  eingabeName = request.getParameter("tfName");	  
	  eingabeJahre = request.getParameter("tfJahre");
      
	  gewicht = Double.parseDouble(eingabeGewicht);
      groesse= Double.parseDouble(eingabeGroesse);
	  jahre = Integer.parseInt(eingabeJahre);
      
	  Person neuePerson = new Person();
	  neuePerson.setGewicht(gewicht);
	  neuePerson.setGroesse(groesse);
	  neuePerson.setGeschlecht(eingabeGeschlecht);
	  neuePerson.setName(eingabeName);
	  neuePerson.setJahre(jahre);
	  neuePerson.berechneBMI();
	  	      
      Datenbankzugriff  aktuellerZugriff = new Datenbankzugriff ();
      aktuellerZugriff.anfuegen(neuePerson);

	  out.println("Ihr BMI beträgt: " + neuePerson.getBMI());
	  out.println("<br><br>");
      out.println(neuePerson.getKommentarGeschlecht());
      out.println("<br><br>");
	  out.println(neuePerson.getKommentarJahre());
	  out.println("<br><br>");
	  
	  Person einePerson = new Person();
      einePerson = aktuellerZugriff.sucheAlleDatensaetze(eingabeName);
	  
	  out.println("Ihre bisherigen Daten: "); 
	  out.println("<table border = 1>");
	  out.println("<tr>");
	  out.println("<th>Name</th><th>Gewicht</th><th>Größe</th><th>Jahre</th><th>Geschlecht</th><th>BMI</th>");
	  out.println("</tr>");  
	  out.println("<tr>");
	  out.println("<td>");
	  out.println(einePerson.getName());
	  out.println("</td>");
	  out.println("<td>");
	  out.println(einePerson.getGewicht());
	  out.println("</td>");
	  out.println("<td>");
	  out.println(einePerson.getGroesse());
	  out.println("</td>");
	  out.println("<td>");
	  out.println(einePerson.getJahre());
	  out.println("</td>");
	  out.println("<td>");
	  out.println(einePerson.getGeschlecht());
	  out.println("</td>");
	  out.println("<td>");
	  out.println(einePerson.getBMI());
	  out.println("</td>");
	  out.println("</tr>");
	 
	  while (aktuellerZugriff.naechsterDatensatz()!= null)
	  {
	  	 out.println("<tr>");
	     out.println("<td>");
	     out.println(einePerson.getName());
	     out.println("</td>");
	     out.println("<td>");
	     out.println(einePerson.getGewicht());
	     out.println("</td>");
	     out.println("<td>");
	     out.println(einePerson.getGroesse());
	     out.println("</td>");
	     out.println("<td>");
	     out.println(einePerson.getJahre());
	     out.println("</td>");
	     out.println("<td>");
	     out.println(einePerson.getGeschlecht());
	     out.println("</td>");
	     out.println("<td>");
	     out.println(einePerson.getBMI());
	     out.println("</td>");
	  	 out.println("</tr>"); 
	  }
	  out.println("</table>");	  

      out.write("\r\n");
      out.write("<h2>Hier können Sie Ihre gespeicherten Daten ändern:</h2>\r\n");
      out.write("<h3>Namensänderung:</h3>\r\n");
      out.write("<form action=\"bmiberechnungDBNameaendern.jsp\" method=\"post\">\r\n");
      out.write(" <table>\r\n");
      out.write("  <tr>\r\n");
      out.write("    <td>Name bisher: </td>\r\n");
      out.write("    <td><input type = \"text\" name =\"tfNameBisher\" value = \"");
 out.println(eingabeName); 
      out.write("\"> </td>\r\n");
      out.write("  </tr> \r\n");
      out.write("  <tr>\r\n");
      out.write("    <td>Name neu: </td>\r\n");
      out.write("    <td><input type = \"text\" name =\"tfNameNeu\"></td>\r\n");
      out.write("  </tr>\r\n");
      out.write("</table>\r\n");
      out.write("<br>\r\n");
      out.write("<input type=\"submit\" value=\"Name ändern oder ohne neuen Namen ->löschen\">\r\n");
      out.write("</form>\r\n");
      out.write("<a href=\"index.html\">zurück zur Dateneingabe</a>\r\n");
      out.write("</body>\r\n");
      out.write("</html>\r\n");
    } catch (java.lang.Throwable t) {
      if (!(t instanceof javax.servlet.jsp.SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try {
            if (response.isCommitted()) {
              out.flush();
            } else {
              out.clearBuffer();
            }
          } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
        else throw new ServletException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
