I have a .jsp file that sends data via the post method to a servlet, but when i try to access the data in the servlet via request.getAttribute(), it prints out "null"
my .jsp file looks like this:
<form name="update" action="UpdateServlet" method="post"
accept-charset="utf-8">
<label>Name:</label><input type="text" name="input_name" id="input_name"><br>
<label>Beschreibung:</label> <input type="text" name="input_beschreibung" id="input_beschreibung"><br>
<input type="hidden" name="input_id" id="input_id">
<input type="submit" value="Okay">
<button type="button" onclick="closeDialog()">Abbrechen</button>
</form>
my servlet looks like this:
public class UpdateServlet extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
System.out.println((String)request.getAttribute("input_id"));
System.out.println((String)request.getAttribute("input_name"));
System.out.println((String)request.getAttribute("input_beschreibung"));
RequestDispatcher rd=request.getRequestDispatcher("LoadServlet");
rd.forward(request, response);
}
part of web.xml:
<servlet>
<servlet-name>UpdateServlet</servlet-name>
<servlet-class>wochenplaner.UpdateServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>UpdateServlet</servlet-name>
<url-pattern>/UpdateServlet</url-pattern>
</servlet-mapping>
i dont understand why the attributes of the request are empty. Thanks in advance!