Example usage for javax.servlet.http HttpSession getAttribute

List of usage examples for javax.servlet.http HttpSession getAttribute

Introduction

In this page you can find the example usage for javax.servlet.http HttpSession getAttribute.

Prototype

public Object getAttribute(String name);

Source Link

Document

Returns the object bound with the specified name in this session, or null if no object is bound under the name.

Usage

From source file:com.kalai.controller.AppendGridStoreController.java

@RequestMapping("/appendgridstore")
public String appendgridstore(ModelMap map, HttpSession session) {
    String username = (String) session.getAttribute("username");
    if (username != null && !username.equals("") && username.trim().length() != 0) {
        map.addAttribute("Status", "UnSuccess_multiple");
        return "AppendGridStore";
    } else {/*from  w w  w . ja va2 s .  c om*/
        return "index";
    }
}

From source file:echec.controller.JoueurController.java

@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
public String jeu(Model model, HttpSession s) {
    Long joueur = (Long) s.getAttribute("idUser");
    model.addAttribute("joueur", serviceJoueur.findOne(joueur));
    return "dashboard.jsp";
}

From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration.java

public static EditConfiguration getConfigFromSession(HttpSession sess, String editKey) {
    Map<String, EditConfiguration> configs = (Map<String, EditConfiguration>) sess
            .getAttribute("EditConfigurations");
    if (configs == null)
        return null;

    EditConfiguration config = configs.get(editKey);
    if (config == null)
        return null;
    else//from ww w  . ja v  a  2  s .com
        return config;
}

From source file:mx.com.quadrum.contratos.controller.crud.GradoController.java

@ResponseBody
@RequestMapping(value = "eliminarGrado", method = RequestMethod.POST)
public String eliminarGrado(Grado grado, BindingResult bindingResult, HttpSession session) {
    if (session.getAttribute("usuario") == null) {
        return SESION_CADUCA;
    }/*w  w w .  j a va  2  s  .co m*/
    return gradoService.eliminar(grado);
}

From source file:mx.com.quadrum.contratos.controller.crud.TipoContratoController.java

@ResponseBody
@RequestMapping(value = "editarTipoContrato", method = RequestMethod.POST)
public String editarTipoContrato(@Valid @ModelAttribute("tipoContrato") TipoContrato tipoContrato,
        BindingResult bindingResult, MultipartFile formato, HttpSession session) {
    if (session.getAttribute("usuario") == null) {
        return SESION_CADUCA;
    }/*w  w w .  jav  a 2  s.  c o m*/
    if (bindingResult.hasErrors()) {
        return ERROR_DATOS;
    }
    return tipoContratoService.editar(tipoContrato, formato);
}

From source file:com.kalai.controller.AppendGridStoreController.java

@RequestMapping("/afterappendgridstore")
public String afterappendgridstore(ModelMap map,
        @ModelAttribute("afterappendgridstore") MultipleInput multipleinputs, HttpSession session) {
    String username = (String) session.getAttribute("username");
    if (!username.equals("") && username.trim().length() != 0) {
        List<MultipleInputFiles> multipleinputfiles = multipleinputs.getMultipleinputfiles();
        map.addAttribute("Status", "Success");
        map.addAttribute("albums", multipleinputfiles);
        return "AppendGridStore";
    } else {/*from ww  w  .  jav a  2 s .c  o m*/
        return "index";
    }
}

From source file:ems.web.controller.other.HireInitController.java

@RequestMapping(value = "/clickApply", method = RequestMethod.POST)
public String hireApply(String content, String email, String subject, MultipartFile file, HttpSession session) {
    MemberDTO member = (MemberDTO) session.getAttribute("loginMember");
    if (member.getType().equals("student")) {

        return resumeServiceImpl.hireApply(content, email, subject, file);
    } else/* www  .jav  a2  s . c o m*/
        return "redirect:../error/errorMessage";

}

From source file:mvc.interceptor.AutorizadorInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object controller)
        throws Exception {

    String uri = request.getRequestURI();
    String contextPath = request.getContextPath();

    if (uri.endsWith(contextPath) || uri.contains("index") || uri.contains("formLogin")
            || uri.contains("efetuaLogin") || uri.contains("listaTarefas") || uri.contains("resources")) {
        return true;
    }//from   w ww  .j  ava2  s  .c  om

    HttpSession session = request.getSession();

    if (session.getAttribute("usuarioLogado") != null) {
        return true;
    }

    response.sendRedirect("formLogin");

    return false;
}

From source file:util.LoginInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
    HttpSession session = request.getSession();
    String token = (String) session.getAttribute("token");
    if (request.getRequestURI().endsWith("efetuarLogin.htm") || (token != null && token.equals("aprovado"))
            || (request.getRequestURI().endsWith("login.htm"))) {
        return true;
    } else {/* w w  w .java2 s  .c  o m*/
        response.sendRedirect("login.htm");
        return false;
    }
}

From source file:mx.com.quadrum.contratos.controller.crud.TipoContratoController.java

@ResponseBody
@RequestMapping(value = "agregarTipoContrato", method = RequestMethod.POST)
public String agregarTipoContrato(@Valid @ModelAttribute("tipoContrato") TipoContrato tipoContrato,
        MultipartFile formato, BindingResult bindingResult, Model model, HttpSession session) {
    if (session.getAttribute("usuario") == null) {
        return SESION_CADUCA;
    }//w  w w  . j ava 2 s  .  c o  m
    if (bindingResult.hasErrors()) {
        return ERROR_DATOS;
    }
    //        model.addAttribute("resultado", tipoContratoService.agregar(tipoContrato, formato));
    //        return "crud/catalogo";
    return tipoContratoService.agregar(tipoContrato, formato);

}