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:com.netstorm.localization.MyLocaleResolver.java

@Override
public void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale) {
    if (locale == null) {
        //determine cur locale
        request.setAttribute(Utils.LOCALE_REQUEST_ATTRIBUTE_NAME, createLocaleBean(request));
    } else {/*from w w  w. j a va  2s . co m*/
        request.setAttribute(Utils.LOCALE_REQUEST_ATTRIBUTE_NAME,
                new LocalesServiceBean(locale_service, getDefaultLocale(), locale));
    }
}

From source file:cn.vlabs.umt.ui.actions.ManageRoleAction.java

public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) {/*  w ww .ja  v  a 2 s . c o  m*/
    RoleService rs = getRoleService();
    Collection<User> users = rs.getRoleMembers("admin");
    request.setAttribute("users", users);
    return mapping.getInputForward();
}

From source file:com.miserablemind.butter.apps.butterApp.controller.ControllerExceptionHandler.java

/**
 * Handles "Not Found" scenario and renders a 404 page.
 *
 * @param request   http request used for getting the URL and wiring config into model
 * @param exception exception that was thrown, in this case {@link com.miserablemind.butter.apps.butterApp.exception.HTTPNotFoundException}
 * @return logical name of a view to render
 *//*www .  j a v a 2 s.c o  m*/
@ResponseStatus(HttpStatus.NOT_FOUND) // 404
@ExceptionHandler(HTTPNotFoundException.class)
public String handleNotFound(HttpServletRequest request, Exception exception) {
    logger.error("[404] Request: " + request.getRequestURL() + " raised " + exception, exception);
    request.setAttribute("configApp", this.config);
    if (Utilities.getAuthUserId() == 0)
        return "guest/errors/404";
    return "errors/404";
}

From source file:com.miserablemind.butter.apps.butterApp.controller.ControllerExceptionHandler.java

/**
 * Handles "Bad Request" scenario and renders a 400 page.
 *
 * @param request   http request used for getting the URL and wiring config into model
 * @param exception exception that was thrown, in this case {@link com.miserablemind.butter.apps.butterApp.exception.HTTPBadRequestException}
 * @return logical name of a view to render
 *///from  w  ww. j a v  a  2  s. c  om
@ResponseStatus(HttpStatus.BAD_REQUEST) // 400
@ExceptionHandler(HTTPBadRequestException.class)
public String handleBadRequest(HttpServletRequest request, Exception exception) {
    logger.error("[400] Request: " + request.getRequestURL() + " raised " + exception, exception);
    request.setAttribute("configApp", this.config);
    if (Utilities.getAuthUserId() == 0)
        return "guest/errors/400";
    return "errors/400";
}

From source file:com.miserablemind.butter.apps.butterApp.controller.ControllerExceptionHandler.java

/**
 * Handles "Internal Server Error" scenario and renders a 500 page.
 *
 * @param request   http request used for getting the URL and wiring config into model
 * @param exception exception that was thrown, in this case {@link com.miserablemind.butter.apps.butterApp.exception.HTTPBadRequestException} or {@link DataAccessException}
 * @return logical name of a view to render
 *///from  www .  ja  v a 2 s .com
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) // 500
@ExceptionHandler({ DataAccessException.class, HTTPInternalServerErrorException.class })
public String handleInternalServerError(HttpServletRequest request, Exception exception) {
    logger.error("[500] Request: " + request.getRequestURL() + " raised " + exception, exception);
    request.setAttribute("configApp", this.config);
    if (Utilities.getAuthUserId() == 0)
        return "guest/errors/500";
    return "errors/500";
}

From source file:com.redhat.rhn.frontend.action.systems.entitlements.EligibleFlexGuestAction.java

/**
 *
 * {@inheritDoc}//from www. j a  v a 2  s . com
 */
@Override
public ActionForward execute(ActionMapping mapping, ActionForm formIn, HttpServletRequest request,
        HttpServletResponse response) {
    request.setAttribute(SELECTABLE, Boolean.TRUE);

    RequestContext requestContext = new RequestContext(request);
    User user = requestContext.getCurrentUser();
    //user.hasRole(RoleFactory.ORG_ADMIN)
    ListSessionSetHelper helper = new ListSessionSetHelper(this, request);
    helper.execute();
    if (helper.isDispatched()) {
        RequestContext context = new RequestContext(request);
        return handleConfirm(helper, context, mapping);
    }

    request.setAttribute("selected_family", getSelectedChannel(requestContext));
    return mapping.findForward(RhnHelper.DEFAULT_FORWARD);
}

From source file:edu.duke.cabig.c3pr.web.study.AmendStudyController.java

@Override
protected Map referenceData(HttpServletRequest request, Object command, Errors e, int page) throws Exception {
    request.setAttribute(FLOW_TYPE, AMEND_STUDY);
    request.setAttribute("amendFlow", "true");

    request.setAttribute("softDelete", "false");
    return super.referenceData(request, command, e, page);
}

From source file:dijalmasilva.controllers.ControladorGrupo.java

@RequestMapping("/{id}")
public String getGroup(@PathVariable Long id, HttpServletRequest req) {
    Grupo grupo = serviceGrupo.buscar(id);
    List<Evento> eventos = serviceEvento.findByIdOfGroup(id);
    req.setAttribute("eventos", eventos);
    req.setAttribute("group", grupo);
    return "otherGroup";
}

From source file:com.netcracker.financeapp.controller.agent.AgentServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    ArrayList<String> agentList = agentService.getAgentNames();
    request.setAttribute("agentList", agentList);

    String currentAgent = request.getParameter("agentListVal");
    if (currentAgent != null && currentAgent != "Select Agent") {

        Agent currAgent = agentService.getAgentByName(currentAgent);
        request.setAttribute("agentNumber", currAgent.getAccountNumber());
        request.setAttribute("agentName", currAgent.getName());
    }/* w ww  .jav  a2s. com*/
    request.setAttribute("clearAgent", "Select Agent");
    request.getRequestDispatcher("agent/agentPage.jsp").forward(request, response);

}

From source file:org.ucll.ip.spring_ip_project.controller.TankController.java

@RequestMapping(method = RequestMethod.POST, value = "/new")
public ModelAndView getNewForm(HttpServletRequest request) {
    ModelAndView view = new ModelAndView("tankForm", "tank", new Tank());
    String name = request.getParameter("player");
    request.setAttribute("player", name);
    view.addObject("name", system.getPlayer(name));
    return view;//ww  w .  j  a va2 s.  c o m
}