Added null check
This commit is contained in:
parent
84d1f065bc
commit
87295e0b5e
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue