Example usage for javax.servlet.http HttpServletRequest setAttribute

List of usage examples for javax.servlet.http HttpServletRequest setAttribute

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest setAttribute.

Prototype

public void setAttribute(String name, Object o);

Source Link

Document

Stores an attribute in this request.

Usage

From source file:net.sourceforge.fenixedu.presentationTier.Action.publico.ShowClassesDispatchAction.java

private void getInfoDegreeCurricularPlan(HttpServletRequest request, Degree degree) {

    InfoDegree infoDegree = ReadDegreeByOID.run(degree.getExternalId());
    request.setAttribute("infoDegree", infoDegree);
}

From source file:dk.itst.oiosaml.sp.service.LoginHandler.java

private void promptIdp(RequestContext context, String returnUrl) throws ServletException, IOException {
    log.debug("Prompting user for IdP");

    Map<String, String> idps = new HashMap<String, String>();
    for (String id : context.getIdpMetadata().getEntityIDs()) {
        StringBuilder url = new StringBuilder(returnUrl);
        if (returnUrl.indexOf('?') > -1) {
            url.append("&");
        } else {/*w ww.  j  a  v  a 2 s. co m*/
            url.append("?");
        }
        url.append(Constants.DISCOVERY_ATTRIBUTE).append("=");
        url.append(Base64.encodeBytes(id.getBytes(), Base64.DONT_BREAK_LINES));
        idps.put(id, url.toString());
    }

    String servlet = context.getConfiguration().getString(Constants.PROP_DISCOVERY_PROMPT_SERVLET, null);
    if (servlet != null) {
        HttpServletRequest request = context.getRequest();
        request.setAttribute("entityIds", idps);
        request.getRequestDispatcher(servlet).forward(request, context.getResponse());
    } else {
        VelocityContext vc = new VelocityContext();
        vc.put("entityIds", idps);

        try {
            HTTPUtils.getEngine().mergeTemplate("/dk/itst/oiosaml/sp/service/idp.vm", vc,
                    context.getResponse().getWriter());
        } catch (Exception e) {
            log.error("Unable to render IdP list", e);
            throw new ServletException(e);
        }
    }

}

From source file:com.appleframework.monitor.security.UserInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
    if (request.getUserPrincipal() != null) {
        //request.setAttribute(SimpleAuthz.USER_PRINCIPAL, request.getUserPrincipal());
        request.setAttribute("userName", request.getUserPrincipal().getName());
    }/*from  w  w  w . java  2 s .  co  m*/
    logger.debug("receive a  page request ");
    return true;
}

From source file:com.bdnc.ecommercebdnc.command.PerfilProduto.java

@Override
public void execute(HttpServletRequest request, HttpServletResponse response) {

    try {//from  w  w  w.j  av a 2s  .co m

        LojaService lojaService = new LojaService();
        Produto produto = lojaService.buscarProduto(Long.parseLong(request.getParameter("idProduto")));
        request.setAttribute("produto", produto);
        request.setAttribute("produtosSugeridos", lojaService.buscarProdutosSugeridos(produto));

        RequestDispatcher dispather = request.getRequestDispatcher("produto.jsp");
        dispather.forward(request, response);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:com.parallax.server.blocklyprop.servlets.PasswordResetServlet.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String token = req.getParameter("token");
    String email = req.getParameter("email");
    req.setAttribute("token", token == null ? "" : token);
    req.setAttribute("email", email == null ? "" : email);
    req.getRequestDispatcher("WEB-INF/servlet/password-reset/do-reset.jsp").forward(req, resp);
}

From source file:com.glaf.core.web.springmvc.MxSystemCacheMgrController.java

@RequestMapping("/view")
public ModelAndView view(HttpServletRequest request, ModelMap modelMap) {
    String key = request.getParameter("key");
    request.setAttribute("cacheValue", CacheFactory.getString(key));
    String jx_view = request.getParameter("jx_view");

    if (StringUtils.isNotEmpty(jx_view)) {
        return new ModelAndView(jx_view, modelMap);
    }/*  w  w w.jav  a 2  s.c om*/

    String x_view = ViewProperties.getString("sys_cache.view");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }
    return new ModelAndView("/modules/sys/cache/view", modelMap);
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.administrativeOffice.candidacy.SelectDFACandidaciesDispatchAction.java

public ActionForward chooseExecutionDegreeInvalid(ActionMapping mapping, ActionForm actionForm,
        HttpServletRequest request, HttpServletResponse response) {
    request.setAttribute("candidacyBean", RenderUtils.getViewState().getMetaObject().getObject());
    return mapping.getInputForward();
}

From source file:dijalmasilva.controllers.ControladorGrupo.java

@RequestMapping("/save")
public String save(GrupoForm g, String idolo, HttpServletRequest req) {
    Usuario user = (Usuario) req.getSession().getAttribute("user");
    Idolo idol = serviceIdolo.buscar(idolo);
    if (idol == null) {
        req.setAttribute("result", "Idolo no cadastrado.");
    } else {//  w w w.  ja  v a2 s .  co m
        Grupo grupo = convertToGrupo(g);
        grupo.setIdolo(idol);
        grupo = serviceGrupo.salvar(user, grupo);

        if (grupo != null) {
            req.setAttribute("result", "Grupo cadastrado com sucesso!");
        } else {
            req.setAttribute("result", "No foi possvel cadastrar grupo.!");
        }
    }
    return "newGroup";
}

From source file:net.prasenjit.auth.config.CustomAjaxAwareHandler.java

/** {@inheritDoc} */
@Override/* www.  j ava 2  s . c o m*/
public void handle(HttpServletRequest request, HttpServletResponse response,
        AccessDeniedException accessDeniedException) throws IOException, ServletException {
    request.setAttribute("javax.servlet.error.status_code", HttpServletResponse.SC_FORBIDDEN);
    request.setAttribute("org.springframework.boot.autoconfigure.web.DefaultErrorAttributes.ERROR",
            accessDeniedException);
    if (accessDeniedException instanceof CsrfException && !response.isCommitted()) {
        // Remove the session cookie so that client knows it's time to obtain a new CSRF token
        String pCookieName = "CSRF-TOKEN";
        Cookie cookie = new Cookie(pCookieName, "");
        cookie.setMaxAge(0);
        cookie.setHttpOnly(false);
        cookie.setPath("/");
        response.addCookie(cookie);
    }

    delegatedAccessDeniedHandler.handle(request, response, accessDeniedException);
}

From source file:com.glaf.base.modules.todo.springmvc.SysTodoController.java

/**
 * TODO//from w ww  .j av  a 2s  .  com
 * 
 * @param modelMap
 * @param request
 * @return
 */
@RequestMapping(params = "method=showList")
public ModelAndView showList(ModelMap modelMap, HttpServletRequest request) {
    RequestUtils.setRequestParameterToAttribute(request);
    List<Todo> rows = todoService.getAllTodoList();
    request.setAttribute("rows", rows);
    return new ModelAndView("/modules/sys/todo/show_list", modelMap);
}