BindingResult result,
HttpSession session) {
List<Toot> tootList;
Toot newToot = new Toot();
try {
User user = (User) session.getAttribute("sessionUser");
if (user == null || user.getId() == null) {
// if they're not in the session, they're probably not logged in
return "redirect:/login";
}
tootList = tootDao.getTootsByUserId(user.getId());
for (Toot itemToot : tootList) {
itemToot.setCustomer(user);
}
Collections.sort(tootList);
user.setTootList(tootList);
newToot.setCustomer(user);
} catch (Exception e) {
e.printStackTrace();
}
model.addAttribute("toot", newToot);