jeudi 5 mars 2015

Passing parameter id onto another page

I want to pass the id of the student from the display.jsp table in to my student.jsp. I have problem getting the id of the student. I can't get to display or get its values. Please do help. Thanks


Here is my jdbc to select the id



public Student getStudentInfo(String id) {
String SQL = "SELECT * FROM student WHERE id = ?";
Event student = jdbcTemplateObject.queryForObject(SQL, new Object[] {id}, new StudentMapper());
return student;

}


display.jsp. Table of Student Info containing the id i want to pass



<tbody>
<c:forEach var="studentinfo" items="${display}">
<tr>
<td><c:out value="${studentinfo.id}"/></td>
<td><c:out value="${studentinfo.name}"/></td>
<td><c:out value="${studentinfo.age}"/></td>
<td><c:out value="${studentinfo.bday}"/></td>
<td><c:out value="${studentinfo.address}"/></td>
<td><button type="submit" class="btn btn-danger btn-xs" name="deleteButton" value="${studentinfo.event_id}" onClick="return confirm('Are you sure you want to delete this student information?')"><i class="fa fa-times"></i>Delete</button>
<td>
<a href="${pageContext.request.contextPath}/student?id=${studentinfo.id}"><c:out value="${studentinfo.id}"/></a>
</td>
</td>
</tr>
</c:forEach>
</tbody>


My Controller



@RequestMapping("/student")
public String studentinfo(HttpServletRequest request, ModelMap model){

try
{
StudentJDBC = (Student)context.getBean("studentJDBC");
System.out.println(request.getParameter("id"));
studentJDBC.getStudentInfo(request.getParameter("id"));
}
catch(Exception e){
System.out.print(e);
}

return "student";
}


And i want to display it from this jsp



<html>
<body>
<label>Student Id</label>
<div class="form-group">
<span class="input-icon">
<span class="input-icon">
<input name="id" value="${studentinfo.id}"/>
</span>
</div>
</body>
</html>

Aucun commentaire:

Enregistrer un commentaire