Problem mit der JSP-Syntax

Ich bin gerade dabei, mich in JSP einzuarbeiten. Dazu habe ich ein Formular geschrieben, mit welchem die Eingabe von Vorname, Name, Email und einem Text ermöglich werden soll.

Ich wollte also mal jsp:useBean ausprobieren, allerdings habe ich einen Syntaxfehler drin, den ich nicht nachvollziehen kann. Vielleicht fällt dieser ja einem JSP-Experten auf.


Hier ist meine JSP-Seite:

Java:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<script type='text/javascript' src="jquery-3.4.1.js"></script>
<link rel="stylesheet" href="custom.css">
<link href="bootstrap-3.3.5/css/bootstrap.min.css" rel="stylesheet">
<script src="bootstrap-3.3.5/js/bootstrap.min.js"></script>
<title></title>
</head>
<body class="body">

    <p id="date">
        Datum:
        <%= (new java.util.Date()).toLocaleString()%></p>

    <form class="form-horizontal" method="POST" action="main.jsp">

        <div class="container">
            <div class="row">
                <div class="control-group col-sm-3">
                    <label id="vorname_label" for="checkIn">Vorname:</label>
                    <div id="vorname_container">
                        <div class="input-group text">
                            <input type="text" id="vorname" name="vorname"
                                class="form-control" autofocus>
                        </div>
                    </div>
                </div>
                <div class="control-group col-sm-9">

                    <label id="nachname_label" for="checkIn">Nachname:</label>
                    <div id="nachname_container">
                        <div class="input-group text">
                            <input type="text" id="nachname" name="nachname"
                                class="form-control">
                        </div>
                    </div>

                </div>

                <div class="container">
                    <div class="row">
                        <div class="col-sm-12">
                            <label id="email_label" for="checkIn">Mail:</label>
                            <div id="email_container">
                                <div class="input-group text">
                                    <input type="text" id="mail" name="mail" class="form-control">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="container">
                <div class="row">
                    <div class="col-sm-6">
                        <textarea id="textarea_motivation" rows="4" cols="50"></textarea>
                    </div>
                    <div class="col-sm-6">
                        <h3>Motivationsschreiben</h3>
                        <p>Hier können sie ein Motivationsschreiben verfassen.</p>
                    </div>
                </div>
            </div>
            <div class="col-sm-2">
                <button type="submit" class="btn btn-success" id="senden">Senden</button>
            </div>
        </div>

    </form>



    <%
   String vorname = request.getParameter("vorname");  String nachname = request.getParameter("nachname"); 
   String mail = request.getParameter("mail");
  

   if(vorname.isEmpty() || nachname.isEmpty() || nachname.isEmpty()) {
      out.println("<font color=\"red\"><p align=\"center\">Bitte alle Felder ausfüllen!</p></font>");
  
   }else{
      
 %>

    <jsp:useBean id="emailwriter" class="IO.Writer" />
    <jsp:setProperty name="email" property="email" value="mail" />

    ${emailwriter.writeEmail}
    <%       
      
   }

%>

</body>
</html>
Hier ist die JAVA-Klasse, die ich mit useBean verwenden will:

Java:
package IO;

import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Writer
{
  private String email = "";

  public void setEmail( String email )
  {
    this.email = email;
  }

  public String getEmail()
  {
    return email;
  }
 
  public void writeEmail(){
      
      writer(this.email);
      
  }
 
  ///////////////////////////////////////////////////

private void writer(String content) {

    String filePathString = "C:\\Users\\andfe\\Desktop\\app.log";
    
    File f = new File(filePathString);
    if(!f.exists()) {

                Path path = Paths.get(filePathString);
                try {
                    Files.createFile(path);
                } catch (IOException e) {
                    
                    e.printStackTrace();
                }
            }
        
    
      try (FileWriter writer = new FileWriter(filePathString);
                 BufferedWriter bw = new BufferedWriter(writer)) {

                 bw.write(content);

            } catch (IOException e) {
                e.printStackTrace();
            }
    
}

 
 
}
… und hier ist meine css:

CSS:
textarea, p, label  {
  min-width: 100%; /* Force element to take up the whole column width */
}

#date{
    margin:5px;
}

#vorname_label, #nachname_label {
    margin-top:26px;
    margin-left:18px;
}

#email_label, #email_container, #vorname_container, #nachname_container {
    margin-left:18px; 
    
}


#senden { margin-top:4px; background-color:grey; }

.body{
    
    background-color: lightblue;
    
}



#textarea_motivation{

    margin-top:26px;

}
 
Passende Stellenanzeigen aus deiner Region:

Neue Themen

Oben