0

I edited textarea on jsp page using servlet and I want to return updated same jsp page. But this jsp page url http://localhost:/studentProfile.jsp?id=1. So I get error.

HTTP Status 500 - java.lang.NumberFormatException: null

How to return updated jsp page in servlet?

Can I use instead 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>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
B.Bus
  • 11
  • 1
  • 2
  • 8
  • what's your exact question? – SatyaTNV Jan 24 '16 at 04:51
  • A partial update of a web page after an action is a need most commonly fulfilled by using AJAX technology. In a JSP, you'll need to write JavaScript to perform the calls and to update the page with the results. In JSF pages, AJAX can sometimes be encapsulated by the controls you place onto the pages without additional JavaScript. – scottb Jan 24 '16 at 05:02
  • It has already been asked here http://stackoverflow.com/questions/12197885/remain-in-same-page-even-after-submitting-jsp-form – SKU_MIG Jan 24 '16 at 05:07

0 Answers0