gt:         Integer eventoI = Integer.parseInt(evento);
context: package spring;
  
  import pojo.*;
  import dao.*;
  import java.io.IOException;
  import java.util.List;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  import javax.mail.MessagingException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.http.HttpSession;
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.ModelMap;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.RequestParam;
  import org.springframework.web.bind.annotation.ResponseBody;
  import org.springframework.web.multipart.MultipartFile;
  import utils.*;
  
  /**
   * Classe MainController
   *
   * @author Matteo Parlato
   */
  @Controller
  public class MainController
  {
  
      boolean ready = true;
      
      public MainController()
      {
          //
      }
      
      // <editor-fold defaultstate="collapsed" desc="AJAX">
      @RequestMapping(value = "/ajaxAddArtist", method = RequestMethod.POST)
      public @ResponseBody
      String ajaxAddArtist(@RequestParam("nome") String nome, @RequestParam("cognome") String cognome)
      {
          Artista art = ArtistiDao.addArtista(nome, cognome);
          String html = "<div class=\"col-md-5 col-sm-5 col-xs-5 col-lg-5\">\n" +
  "                           <label style=\"font-weight: normal;\"><input type=\"checkbox\" name=\"artists\" value=\""+ art.getId() +"\"> " + nome + " " + cognome + "</label>\n" +
  "                      </div>";
          return html;
      }
      // </editor-fold>
  
      // <editor-fold defaultstate="collapsed" desc="/">
      @RequestMapping(value = "/", method = RequestMethod.GET)
      public String index(ModelMap map, HttpServletRequest request)
      {
          Membro membro = (Membro) request.getSession().getAttribute("userinfo");
          
          if(membro != null){
              request.setAttribute("eventsList", EventiDao.retrieveByUserZoneInterest(membro.getZona(), membro.getCategoriaList()));
          }else{
              request.setAttribute("eventsList", EventiDao.retrieveAll());
          }
          return "index";
      }
  
      // </editor-fold>
      
      // <editor-fold defaultstate="collapsed" desc="Front-end">
      // <editor-fold defaultstate="collapsed" desc="Registrazione">
      @RequestMapping(value = "/registration", method = RequestMethod.GET)
      public String registration(ModelMap map)
      {
          return "registration";
      }
  
      @RequestMapping(value = "/doRegistration",
              params
              =
              {
                  "username", "password", "name", "surname", "mail", "zone"
              }, method = RequestMethod.POST)
      public String doRegistration(ModelMap map, HttpServletRequest request, @RequestParam(value = "username") String username, @RequestParam(value = "password") String password, @RequestParam(value = "name") String name, @RequestParam(value = "surname") String surname, @RequestParam(value = "mail") String mail, @RequestParam(value = "zone") String zone)
      {
          Membro user = MembriDao.register(username, password, name, surname, mail, zone);
          if(user != null)
          {
              request.getSession().setAttribute("userinfo", user);
              return "redirect:selectInterests";
          }
          return "redirect:registration";
      }
  
      @RequestMapping(value = "/selectInterests", method = RequestMethod.GET)
      public String selectInterests(ModelMap map)
      {
          map.put("categoriesList", CategorieDao.retrieveAll());
          return "selectInterests";
      }
  
      @RequestMapping(value = "/doInterests",
              params
              =
              {
                  "categories"
              }, method = RequestMethod.POST)
      public String doInterests(ModelMap map, HttpServletRequest request, @RequestParam(value = "categories") List<Integer> categories)
      {
          Membro user = (Membro) request.getSession().getAttribute("userinfo");
          user = MembriDao.setInterestsWCats(categories, user.getUsername());
          request.getSession().setAttribute("userinfo", user);
          return "redirect:profile";
      }
  
      // </editor-fold>
      
      // <editor-fold defaultstate="collapsed" desc="Login e Logout">
      @RequestMapping(value = "/doLogin", params
              =
              {
                  "username", "password"
              }, method = RequestMethod.POST)
      public void doLogin(ModelMap map, HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "username") String username, @RequestParam(value = "password") String password)
      {
          Membro user = MembriDao.checkLogin(username, password);
          String referer = "http://localhost:8080/WebCommunity/registration";
          if (user != null)
          {
              request.getSession().setAttribute("userinfo", user);
              referer = request.getHeader("Referer");
          }
          try
          {
              response.sendRedirect(referer);
          } catch (IOException ex)
          {
              Logger.getLogger(MainController.class.getName()).log(Level.SEVERE, null, ex);
          }
      }
  
      @RequestMapping(value = "/doLogout", method = RequestMethod.GET)
      public String doLogout(ModelMap map, HttpServletRequest request)
      {
          HttpSession session = request.getSession();
          session.setAttribute("username", null);
          session.invalidate();
          return "redirect:./";
      }
  
      // </editor-fold>
      
      // <editor-fold defaultstate="collapsed" desc="Profilo">
      @RequestMapping(value = "/profile", method = RequestMethod.GET)
      public String profile(ModelMap map)
      {
          map.put("categoriesList", CategorieDao.retrieveAll());
          map.put("artistsList", ArtistiDao.retrieveAll());
          return "profile";
      }
  
      @RequestMapping(value = "/doRemove", method = RequestMethod.GET)
      public String doRemove(ModelMap map, HttpServletRequest request)
      {
          Membro user = (Membro) request.getSession().getAttribute("userinfo");
          MembriDao.remove(user.getUsername());
          HttpSession session = request.getSession();
          session.setAttribute("username", null);
          session.invalidate();
          return "redirect:./";
      }
  
      @RequestMapping(value = "/doChangePassword", method = RequestMethod.POST)
      public String doChangePassword(ModelMap map, HttpServletRequest request, @RequestParam(value = "password") String password)
      {
          Membro user = (Membro) request.getSession().getAttribute("userinfo");
          user = MembriDao.changePassword(password, user.getUsername());
          request.getSession().setAttribute("userinfo", user);
          return "redirect:profile";
      }
      
      @RequestMapping(value = "/removeUserEvent", method = RequestMethod.GET)
      public String removeUserEvent(ModelMap map, HttpServletRequest request, @RequestParam(value = "id") String id)
      {
          EventiDao.removeEvento(Integer.parseInt(id));
          Membro user = (Membro) request.getSession().getAttribute("userinfo");
          request.getSession().setAttribute("userinfo", MembriDao.getUserInfo(user.getUsername()));
          return "redirect:profile";
      }
      
      @RequestMapping(value = "/doChangePersonalInformations", method = RequestMethod.POST)
      public String doChangePersonalInformations(ModelMap map, HttpServletRequest request, @RequestParam(value = "name") String name, @RequestParam(value = "surname") String surname, @RequestParam(value = "mail") String mail, @RequestParam(value = "zona") String zona)
      {
          Membro user = (Membro) request.getSession().getAttribute("userinfo");
          user = MembriDao.updateProfileInformations(name, surname, mail, user.getUsername(), zona);
          request.getSession().setAttribute("userinfo", user);
          return "redirect:profile";
      }
  
      @RequestMapping(value = "/deleteInterest", method = RequestMethod.GET)
      public String deleteInterest(ModelMap map, HttpServletRequest request, @RequestParam(value = "id") Integer id)
      {
          Membro user = (Membro) request.getSession().getAttribute("userinfo");
          user = MembriDao.deleteInterest(id, user.getUsername());
          request.getSession().setAttribute("userinfo", user);
          return "redirect:profile";
      }
  
      @RequestMapping(value = "/deletePost", method = RequestMethod.GET)
      public String deletePost(ModelMap map, HttpServletRequest request, @RequestParam(value = "id") Integer id)
      {
          Membro user = (Membro) request.getSession().getAttribute("userinfo");
          user = MembriDao.removePost(id, user.getUsername());
          request.getSession().setAttribute("userinfo", user);
          return "redirect:profile";
      }
      
      @RequestMapping(value = "/updateUserEvent", method = RequestMethod.POST)
      public String updateUserEvent(ModelMap map, HttpServletRequest request, @RequestParam("eventoID") String id, @RequestParam("titolo") String titolo, @RequestParam("luogo") String luogo, @RequestParam("data") String data, @RequestParam("categoria") String categoria, @RequestParam("descrizione") String descrizione, @RequestParam(value = "artists") List<Integer> artists)
      {
          if (ParseUtils.tryParseInt(categoria) && ParseUtils.tryParseInt(id))
          {
              EventiDao.updateEvento(Integer.parseInt(id), titolo, luogo, data, Integer.parseInt(categoria), descrizione, artists);
          }
          Membro user = (Membro) request.getSession().getAttribute("userinfo");
          request.getSession().setAttribute("userinfo", MembriDao.getUserInfo(user.getUsername()));
          return "redirect:profile";
      }
      
      @RequestMapping(value = "/addProfileArtist", method = RequestMethod.POST)
      public String addProfileArtist(ModelMap map, @RequestParam("nome") String nome, @RequestParam("cognome") String cognome)
      {
          ArtistiDao.addArtista(nome, cognome);
          return "redirect:profile";
      }
  
      @RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
      String uploadFileHandler(ModelMap map, HttpServletRequest request, @RequestParam("file") MultipartFile file)
      {
          Membro user = (Membro) request.getSession().getAttribute("userinfo");
                  
          user = MembriDao.setAvatar(user.getUsername(), BlobUtils.createTempFile(file));
  
          request.getSession().setAttribute("userinfo", user);
          
          
          return "redirect:profile";
      }
      
      @RequestMapping(value = "/userUploadEventImage", method = RequestMethod.POST)
      String userUploadEventImage(ModelMap map, HttpServletRequest request, @RequestParam("file") MultipartFile file, @RequestParam("eventID") String id)
      {
          if (file != null && ParseUtils.tryParseInt(id))
          {
              EventiDao.setImmagine(Integer.parseInt(id), BlobUtils.createTempFile(file));
          }
          
          Membro user = (Membro) request.getSession().getAttribute("userinfo");
          request.getSession().setAttribute("userinfo", MembriDao.getUserInfo(user.getUsername()));
          
          return "redirect:profile";
      }
      // </editor-fold>
      
      // <editor-fold defaultstate="collapsed" desc="Categorie">
      @RequestMapping(value = "/categories", method = RequestMethod.GET)
      public String categories(ModelMap map)
      {
          map.put("catList", CategorieDao.retrieveAll());
          return "categories";
      }
  
      // </editor-fold>
      
      // <editor-fold defaultstate="collapsed" desc="Artisti">
      @RequestMapping(value = "/artists", method = RequestMethod.GET)
      public String artists(ModelMap map)
      {
          map.put("artistsList", ArtistiDao.retrieveAll());
          return "artists";
      }
      
      @RequestMapping(value = "/artistDetails", params = {"id"}, method = RequestMethod.GET)
      public String artistsDetails(ModelMap map, @RequestParam(value = "id") Integer id)
      {
          map.put("artistItem", ArtistiDao.retrieveSingle(id));
          return "artistDetails";
      }
  
      // </editor-fold>
      
      // <editor-fold defaultstate="collapsed" desc="Eventi">
      @RequestMapping(value = "/events", params = {"category", "name"}, method = RequestMethod.GET)
      public String events(ModelMap map, HttpServletRequest request, @RequestParam(value = "category") String categoryID, @RequestParam(value = "name") String categoryName)
      {
          if (!categoryID.equals("0"))
          {
              map.put("eventList", EventiDao.retrieveByCat(categoryID));
              map.put("categoriesList", CategorieDao.retrieveAll());
              map.put("artistsList", ArtistiDao.retrieveAll());
              map.put("categoryName", categoryName);
          } else
          {
              map.put("eventList", EventiDao.retrieveAll());
              map.put("categoriesList", CategorieDao.retrieveAll());
              map.put("artistsList", ArtistiDao.retrieveAll());
              map.put("categoryName", "Eventi");
          }
          return "events";
      }
  
      @RequestMapping(value = "/events", method = RequestMethod.GET)
      public String events(ModelMap map, HttpServletRequest request)
      {
          if(ready)
          {
              map.put("eventList", EventiDao.retrieveAll());
              map.put("categoriesList", CategorieDao.retrieveAll());
              map.put("artistsList", ArtistiDao.retrieveAll());
              map.put("categoryName", "Eventi");
          }
          ready = true;
          return "events";
      }
      
      @RequestMapping(value = "/orderEventsByDate", method = RequestMethod.GET)
      public String orderEventsByDate(ModelMap map)
      {
          ready = false;
          map.put("eventList", EventiDao.orderEventsByDate());
          map.put("categoriesList", CategorieDao.retrieveAll());
          map.put("artistsList", ArtistiDao.retrieveAll());
          map.put("subtitle", " ordinati per data");
          map.put("categoryName", "Eventi");
          return "events";
      }
      
      @RequestMapping(value = "/orderEventsByTitle", method = RequestMethod.GET)
      public String orderEventsByTitle(ModelMap map)
      {
          ready = false;
          map.put("eventList", EventiDao.orderEventsByTitle());
          map.put("categoriesList", CategorieDao.retrieveAll());
          map.put("artistsList", ArtistiDao.retrieveAll());
          map.put("subtitle", " ordinati per titolo");
          map.put("categoryName", "Eventi");
          return "events";
      }
      
      @RequestMapping(value = "/orderEventsByCategory", method = RequestMethod.GET)
      public String orderEventsByCategory(ModelMap map)
      {
          ready = false;
          map.put("eventList", EventiDao.orderEventsByCategory());
          map.put("categoriesList", CategorieDao.retrieveAll());
          map.put("artistsList", ArtistiDao.retrieveAll());
          map.put("subtitle", " ordinati per categoria");
          map.put("categoryName", "Eventi");
          return "events";
      }
  
      @RequestMapping(value = "/eventDetail", method = RequestMethod.GET)
      public String eventDetail(ModelMap map, @RequestParam(value = "id") String id)
      {
          map.put("eventDetail", EventiDao.retrieveSingle(id));
          map.put("postList", PostDao.retrieveByEvent(Integer.parseInt(id)));
          return "eventDetail";
      }
      
      @RequestMapping(value = "/addEvent", method = RequestMethod.POST)
      public String addEvent(ModelMap map, HttpServletRequest request, @RequestParam("titolo") String titolo, @RequestParam("luogo") String luogo, @RequestParam("data") String data, @RequestParam("categoria") String categoria, @RequestParam("descrizione") String descrizione, @RequestParam("promotore") String promotore, @RequestParam(value = "artists") List<Integer> artists)
      {
          if (ParseUtils.tryParseInt(categoria))
          {
              EventiDao.addEvento(titolo, luogo, data, Integer.parseInt(categoria), descrizione, promotore, artists);
          }
          
          Membro user = (Membro) request.getSession().getAttribute("userinfo");
          request.getSession().setAttribute("userinfo", MembriDao.getUserInfo(user.getUsername()));
          
          map.put("eventList", EventiDao.retrieveAll());
          map.put("categoriesList", CategorieDao.retrieveAll());
          map.put("categoryName", "Eventi");
          return "redirect:events";
      }
      
      @RequestMapping(value = "/addUserArtist", method = RequestMethod.POST)
      public String addUserArtist(ModelMap map, @RequestParam("nome") String nome, @RequestParam("cognome") String cognome)
      {
          ArtistiDao.addArtista(nome, cognome);
          return "redirect:events";
      }
  
      @RequestMapping(value = "/commento", params =
      {
          "comm",
          "evento",
          "voto"
      },
              method = RequestMethod.GET)
      public void commento(ModelMap map, HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "comm") String comm, @RequestParam(value = "evento") String evento, @RequestParam(value = "voto") String voto)
      {
          Membro user = (Membro) request.getSession().getAttribute("userinfo");
  
  