Reputation: 21
Hello i can't get any value from a from in my index.jsp file. I'm using tomcat7, after running index.jsp and clicking send button nothing happen. System.out.prinln() print nothinig or null ;(
index.jsp
%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title></title>
</head>
<body>
<form acton="addnewtask.jsp" method="post" >
<label for="name">Name</label>
<input type="text" class="form-control" id="name" placeholder="Name">
<button type="submit" class="btn btn-danger">Add</button>
</body>
</html>
addnewtask.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
String s = request.getParameter("name");
System.out.println(s);
%>
Do you know what am i doing wrong ?
Upvotes: 0
Views: 41
Reputation: 41
String s = request.getParameter("xyz");
Add a name to your input box
<form action="addnewtask.jsp" method="post" >
<label for="name">Name</label>
<input type="text" class="form-control" name="xyz" id="name" placeholder="Name">
<button type="submit" class="btn btn-danger">Add</button>
<form>
Upvotes: 0
Reputation: 822
This line allows you to get a parameter with its name not its id :
String s = request.getParameter("name");
Add a name to your input and correct the typo of the attribute action of your form :
<form action="addnewtask.jsp" method="post" >
<label for="name">Name</label>
<input name="name" type="text" class="form-control" id="name" placeholder="Name">
<button type="submit" class="btn btn-danger">Add</button>
<form>
Upvotes: 2