Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package controllers; import DAO.Factory; import java.sql.SQLException; import java.util.List; import java.util.Map; import javax.servlet.http.HttpSession; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.portlet.ModelAndView; @Controller @RequestMapping("/adminpanel.htm") public class AdminPanelController { @RequestMapping(method = RequestMethod.GET) public String showForm(Map map, HttpSession session) throws SQLException { if (session.getAttribute("role") == null || !session.getAttribute("role").equals("admin")) { return "redirect: index.htm"; } List users = Factory.getInstance().getUserDAO().getAllUsers(); map.put("users", users); return "adminpanel"; } }