Was steht denn bei dir in Zeile 41?
Kannst du bitte dein Code nochmal posten.
Hier ist mein Code und damit geht's:
Kannst du bitte dein Code nochmal posten.
Hier ist mein Code und damit geht's:
Java:
package servlets;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Namen extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
String name = request.getParameter("nameneingabe");
String mail = request.getParameter("maileingabe");
String text = request.getParameter("texteingabe");
System.out.println("Hier ist Servlet Namen: doGet");
DatenspeicherBean bean = (DatenspeicherBean) request.getSession().getAttribute("speicherbean");
if (bean == null)
{
bean = new DatenspeicherBean();
request.getSession().setAttribute("speicherbean", bean);
}
bean.setName(name);
bean.setEmail(mail);
bean.setText(text);
RequestDispatcher dispatcher = request.getRequestDispatcher("index.jsp");
dispatcher.forward(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
doGet(request, response);
}
}
HTML:
<%@ page language= "java" contentType="text/html"%>
<HTML>
<HEAD>
<TITLE>Philips Servlet Test</TITLE>
</HEAD>
<BODY>
<h1 align="center">Test Eintrag:</h1>
<%out.println(session.getAttribute("speicherbean")); %>
<jsp:getProperty name="speicherbean" property="name" />
<form action="namen" method="POST">
<table border="0" align="center">
<tr>
<td>Namen eingeben :</td>
<td><input type="text" name="nameneingabe" size="20"></td>
</tr>
<tr>
<td>E-Mail eingeben :</td>
<td><input type="text" name="maileingabe" size="20"></td>
</tr>
<tr>
<td>Text eingeben :</td>
</tr>
</table>
<table border="0" align="center">
<tr>
<td><textarea name="texteingabe" cols="31" rows="10"></textarea></td>
</tr>
</table>
<table border="0" align="center">
<tr>
<td><input type="SUBMIT" NAME="SUBMIT" VALUE="Senden"></td>
<td><input type="reset" NAME="RESET" VALUE="Loeschen"></td>
</tr>
</table>
</form>
</body>
</html>