1protected void doPost(HttpServletRequest request, HttpServletResponse response)
2 throws ServletException, IOException {
3 // Note that unless except in certain cases (IoC)
4 // this scenario is quite easy to avoid
5 Object_DTO object_DTO = null;
6
7 if(request.getParameter("parameter").equals("hello")) {
8 object_DTO = new Object_DTO(); // here null object initialized to a new object
9 object_DTO.setAttr("attr");
10 ...
11 } else if (request.getParameter("parameter").equals("goodbye")) {
12 object_DTO = new Object_DTO();
13 }
14
15 if (object_DTO == null) {
16 // Bad response
17 }
18}
19