title: Spring MVC Pass multiple list from controller to jsp
body: <p>I have two objects <code>Employee</code> and <code>Department</code> Employee contains the <code>dept_id</code>. What i want to do is display the content of <code>Employee</code> in a table in jsp page. But instead of displaying <code>dept_id</code> i want to display <code>dept_name</code> from <code>Department</code> table. So far i have my controller method as:</p>
  
  <pre><code>public ModelAndView viewEmployee(HttpServletRequest request,
              HttpServletResponse response) throws Exception {
  
          List&lt;Employee&gt; employeeList = employeeService.getAllEmployee();
          List&lt;Department&gt; departmentList = new ArrayList&lt;Department&gt;();
          for (Employee e : employeeList) {
              departmentList.add(departmentService.getDepartment(e.getDept_id()));
          }
          Map&lt;String, Object&gt; model = new HashMap&lt;String, Object&gt;();
          model.put("employee", employeeList);
          model.put("department", departmentList);
  
          return new ModelAndView("viewEmployee", "model", model);
      } 
  </code></pre>
  
  <p><strong>viewEmployee.jsp</strong></p>
  
  <pre><code>&lt;table border="1px" bordercolor="black" width=80% align="center"&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Name&lt;/td&gt;
                      &lt;td&gt;Gender&lt;/td&gt;
                      &lt;td&gt;Salary&lt;/td&gt;
                      &lt;td&gt;Department&lt;/td&gt;
                      &lt;td&gt;Action&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;c:forEach items="${model.employeeList}" var="element"&gt;
  
                      &lt;tr&gt;
                          &lt;td&gt;&lt;c:out value="${element.name}" /&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;c:out value="${element.gender}" /&gt;&lt;/td&gt;
  
                          &lt;td&gt;&lt;c:out value="${element.salary}" /&gt;&lt;/td&gt;
  
                          &lt;td&gt;display Department Name here &lt;/td&gt;
  
                          &lt;td&gt;&lt;a
                              href="&lt;c:url value="editEmployee.htm"&gt;  
                      &lt;c:param name="emp_id" value="${element.id}"/&gt;  
          &lt;/c:url&gt;  
      "&gt;Edit&lt;/a&gt;
                              &lt;a
                              href="&lt;c:url value="deleteEmployee.htm"&gt;  
                      &lt;c:param name="emp_id" value="${element.id}"/&gt;  
          &lt;/c:url&gt;  
      "&gt;Delete&lt;/a&gt;
  
                          &lt;/td&gt;
                      &lt;/tr&gt;
  
                  &lt;/c:forEach&gt;
              &lt;/table&gt;
  </code></pre>
  
  <p>Any help? I am not being able to display the map content to the jsp page.</p>