Added null check

This commit is contained in:
sampadawagde 2020-10-26 20:20:38 +05:30
parent 84d1f065bc
commit 87295e0b5e
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);