title: How to load default image in if condition?
body: <p>i have <code>JSP Servlet</code> web  application. it has <code>ViewUserServlet.java</code> file . look at if conditions. some time <code>img2</code> and <code>img3</code> is null. in that time <code>img2</code>and <code>img3</code>equals to <code>img</code>. i wants to load " web content " default <code>img</code> or another file path image, without <code>img2</code> and <code>img3</code> equals to <code>img</code> . please help me how to do that.</p>
  
  <pre><code>try {
          // This will load the MySQL driver, each DB has its own driver
          Class.forName("com.mysql.jdbc.Driver");
  
          // Setup the connection with the DB
          Connection connection = DriverManager.getConnection(Settings.connectionString);
  
          // Statements allow to issue SQL queries to the database
          Statement statement = connection.createStatement();
  
          // set query
          String query = "SELECT * FROM signup WHERE user_id = '"+userId+"'";
  
          // get result set
          ResultSet rs = statement.executeQuery(query);
          if(rs.next()) {
              //found
              // decode images
              java.sql.Blob img = rs.getBlob("image");
              byte[] imgData = img.getBytes(1,(int)img.length());
              byte[] encodeBase64 = Base64.encodeBase64(imgData);
              String base64Encoded = new String(encodeBase64, "UTF-8");
  
              java.sql.Blob img2 = rs.getBlob("nic");
  
              if(img2==null){img2 = rs.getBlob("image");
              }
  
              byte[] imgData2 = img2.getBytes(1,(int)img2.length());
              byte[] encodeBase64_2 = Base64.encodeBase64(imgData2);
              String base64Encoded2 = new String(encodeBase64_2, "UTF-8");
  
  
              java.sql.Blob img3 = rs.getBlob("certificate");
  
              if(img3==null){img3 = rs.getBlob("image");
              }
  
              byte[] imgData3 = img3.getBytes(1,(int)img3.length());
              byte[] encodeBase64_3 = Base64.encodeBase64(imgData3);
              String base64Encoded3 = new String(encodeBase64_3, "UTF-8");
  
              // get user data
              UserModel user = new UserModel(rs.getString("user_id"), rs.getString("first_name"), rs.getString("last_name"), rs.getString("email"),
                      rs.getString("user_name"), base64Encoded, rs.getString("address"), rs.getString("phone"), 
                      rs.getString("location"), rs.getString("company_name"), rs.getString("type"), base64Encoded2, base64Encoded3);
  
              // store user data and redirect to its related home page according to its type
              if(user.getType().equals("customer")){
                  RequestDispatcher RequetsDispatcherObj =request.getRequestDispatcher("/view_user_customer.jsp");
                  request.getSession().setAttribute("customer",user);
                  RequetsDispatcherObj.forward(request, response);
  
              }else if(user.getType().equals("seller")){
                  RequestDispatcher RequetsDispatcherObj =request.getRequestDispatcher("/view_user_seller.jsp");
                  request.getSession().setAttribute("seller",user);
                  RequetsDispatcherObj.forward(request, response);
  
              }
          }
          else{
              //not found
              PrintWriter out = response.getWriter();
              out.println("&lt;script type=\"text/javascript\"&gt;");
              out.println("alert('Invalid Credentials!');");
              out.println("location='login.jsp';");
              out.println("&lt;/script&gt;");
          }
  
          statement.close();
          connection.close();
  
      } catch (Exception e) {
          e.printStackTrace();
      } 
  </code></pre>