Merge pull request #10208 from sampada07/master

Added null check
This commit is contained in:
Loredana Crusoveanu 2020-10-26 17:29:11 +02:00 committed by GitHub
commit d73b78710e
1 changed files with 7 additions and 4 deletions

View File

@ -1,6 +1,5 @@
package com.baeldung.servlets;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
@ -18,10 +17,14 @@ public class UpdateServlet extends HttpServlet {
HttpSession session = request.getSession(false);
session.setAttribute("userName", request.getParameter("userName"));
session.setAttribute("age", request.getParameter("age"));
if (session != null) {
session.setAttribute("userName", request.getParameter("userName"));
session.setAttribute("age", request.getParameter("age"));
request.setAttribute("sessionData", session);
}
request.setAttribute("sessionData", session);
RequestDispatcher requestDispather = request.getRequestDispatcher("update.jsp");
requestDispather.forward(request, response);