我使用servlet在jsp页面上编辑了textarea,我想返回更新的同一个jsp页面。但是这个jsp页面网址http://localhost:/studentProfile.jsp?id=1。 所以我得到了错误。
HTTP状态500 - java.lang.NumberFormatException:null
如何在servlet中返回更新的jsp页面?
我可以使用response.sendRedirect("studentProfile.jsp")
吗?
ProfileServlet:
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String comment = request.getParameter("comment");
int case = new ProfileDao().insertComment(comment);
response.sendRedirect("studentProfile.jsp");
}
studentProfile.jsp:
<form action="studentProfile" method="post">
<div class="form-group">
<textarea name="comment" class="form-control"></textarea>
</div>
<button type="submit" class="btn btn-success"></span>Submit</button>
<h2><small>Posts</small></h2>
<c:forEach items="${profile}" var="pro">
<textarea readonly name="comment">${pro.comment}</textarea>
</c:forEach>
</form>