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.redhat.rhn.frontend.action.channel.manage.EditChannelAction.java

private static void setupForm(HttpServletRequest request, DynaActionForm form) {
    RequestContext ctx = new RequestContext(request);
    prepDropdowns(ctx, null);/* w w w.ja  v a 2  s . c om*/
    Long cid = ctx.getParamAsLong("cid");

    if (cid != null) {
        Channel c = ChannelManager.lookupByIdAndUser(cid, ctx.getCurrentUser());
        if (!UserManager.verifyChannelAdmin(ctx.getCurrentUser(), c)) {
            throw new PermissionException(RoleFactory.CHANNEL_ADMIN);
        }

        form.set(NAME, c.getName());
        request.setAttribute(CHANNEL_LABEL, c.getLabel());
        request.setAttribute(CHANNEL_NAME, c.getName());

        if (c.getSources().isEmpty()) {
            request.setAttribute("last_sync", "");
        } else {
            String lastSync = LocalizationService.getInstance().getMessage("channel.edit.repo.neversynced");
            if (c.getLastSynced() != null) {
                lastSync = LocalizationService.getInstance().formatCustomDate(c.getLastSynced());
            }
            request.setAttribute("last_sync", lastSync);
            if (!ChannelManager.getLatestSyncLogFiles(c).isEmpty()) {
                request.setAttribute("log_url",
                        DownloadManager.getChannelSyncLogDownloadPath(c, ctx.getCurrentUser()));
            }

        }
        if (c.isGloballySubscribable(ctx.getCurrentUser().getOrg())) {
            form.set(SUBSCRIPTIONS, "all");
        } else {
            form.set(SUBSCRIPTIONS, "selected");
        }

        setupFormHelper(request, form, c);

    } else {
        // default settings
        String channelName = LocalizationService.getInstance()
                .getMessage("frontend.actions.channels.manager.create");
        request.setAttribute(CHANNEL_NAME, channelName);
        form.set(ORG_SHARING, "private");
        form.set(SUBSCRIPTIONS, "all");
        form.set(CHECKSUM, "sha1");
    }
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.student.candidacy.EditMissingCandidacyInformationDA.java

public ActionForward prepareEditPostback(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) {//  ww w  .  j  av  a2 s  . c  o  m

    request.setAttribute("personalInformationsWithMissingInformation",
            getPersonalInformationsWithMissingInfo());
    PersonalInformationBean personalInformationBean = getRenderedObject("personalInformationBean");
    personalInformationBean.resetInstitutionAndDegree();
    request.setAttribute("personalInformationBean", personalInformationBean);
    RenderUtils.invalidateViewState();

    return mapping.findForward("editMissingPersonalInformation");
}

From source file:com.teamexception.reseravationmaven.controller.EquipmentController.java

@RequestMapping(value = "editEquipment", method = RequestMethod.GET)
public String getAllEquipments(HttpServletRequest request) throws ClassNotFoundException, SQLException {
    ArrayList<Equipment> equipmentList = equipmentdao.getAllEquipments("F0000000001");
    request.setAttribute("equipmentList", equipmentList);
    return "facilitator/predefinedServices/editEquipment";
}

From source file:com.wx.spring.controller.SalesController.java

@RequestMapping(value = "/viewSaleRecord", method = RequestMethod.GET)
public String viewSalesRecord(@RequestParam String SaleRecordId, HttpServletRequest request, Model model) {
    System.out.println("Enter:Run at Controller: SalesController:getAllCustomers");

    System.out.println("recId:" + SaleRecordId);

    request.setAttribute("saleRec", saleService.findSalesRecordById(SaleRecordId));
    request.setAttribute("totalSalesCls", 100);
    request.setAttribute("totalUsedCls", 40);
    model.addAttribute("saleInfo", new SaleInfoBean());
    System.out.println("Outer:Run at Controller: SalesController:getAllCustomers");
    return "Sale/viewSale";

}

From source file:dijalmasilva.controllers.User.java

@RequestMapping("/login")
public String login(String login, String password, HttpServletRequest req) {

    Usuario usuarioLogado = service.login(login, password);

    if (usuarioLogado != null) {
        req.getSession().setAttribute("usuarioLogado", usuarioLogado);
        req.setAttribute("result", "Bem vindo!");
    } else {/*from w w  w .j  a va 2  s.  c  om*/
        req.setAttribute("result", "Usurio ou senha invlidos.");
    }

    return "home";
}

From source file:org.extremesite.controller.SelectedPresidentsController.java

protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    SelectedPresidentsUtils.saveSelectedPresidentsIDs(request);
    Collection presidents = presidentsService.getPresidents();
    request.setAttribute("presidents", presidents);
    return new ModelAndView(successView);
}

From source file:com.gst.infrastructure.security.service.CustomAuthenticationFailureHandler.java

/**
 * Caches the {@code AuthenticationException} for use in view rendering.
 * <p>//from  w w  w.  j  a v  a  2 s  . c  o m
 * If {@code forwardToDestination} is set to true, request scope will be
 * used, otherwise it will attempt to store the exception in the session. If
 * there is no session and {@code allowSessionCreation} is {@code true} a
 * session will be created. Otherwise the exception will not be stored.
 */
protected final void saveException(final HttpServletRequest request, final AuthenticationException exception) {
    if (this.forwardToDestination) {
        request.setAttribute(WebAttributes.AUTHENTICATION_EXCEPTION, exception);
    } else {
        final HttpSession session = request.getSession(false);

        if (session != null || this.allowSessionCreation) {
            request.getSession().setAttribute(WebAttributes.AUTHENTICATION_EXCEPTION, exception);
        }
    }
}

From source file:com.bitranger.parknshop.admin.PropHolder.java

public void inject(HttpServletRequest request) {
    request.setAttribute("psItemDAO", psItemDAO);
    request.setAttribute("psCustomerDAO", psCustomerDAO);
    request.setAttribute("psOrderDAO", psOrderDAO);
    request.setAttribute("psSellerDAO", psSellerDAO);
    request.setAttribute("psShopDAO", psShopDAO);

    request.setAttribute("psNoticeAdminDAO", psNoticeAdminDAO);

    request.setAttribute("psAdItemDAO", psAdItemDAO);
    request.setAttribute("psPromotItemDAO", psPromotItemDAO);
}

From source file:com.netcracker.financeapp.controller.bank_card.BankCardServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    ArrayList<String> bankCardNumbers = bankCardService.getBankCardNumbers();
    request.setAttribute("cardList", bankCardNumbers);

    String currentCard = request.getParameter("cardListVal");
    if (currentCard != null && currentCard != "Select Card") {

        BankCard currCard = bankCardService.getBankCardByNumber(currentCard);
        request.setAttribute("cardNumber", currCard.getCardNumber());
        request.setAttribute("currentAmount", currCard.getAmount());
        request.setAttribute("ownerName", currCard.getOwnerName());
        request.setAttribute("ownerSurname", currCard.getOwnerSurname());
        request.setAttribute("expireMonth", currCard.getExpireMonth());
        request.setAttribute("expireYear", currCard.getExpireYear());
        request.setAttribute("cvv", currCard.getCvv());
    }/* w  w  w.  jav a  2s.  c o  m*/
    request.setAttribute("clearCard", "Select Card");
    request.getRequestDispatcher("bankCard/bankCardPage.jsp").forward(request, response);

}

From source file:com.rsmart.certification.impl.LocaleHandlerInterceptor.java

public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
        Object object) throws Exception {
    ResourceLoader rb = new ResourceLoader();
    Locale locale = rb.getLocale();
    httpServletRequest.setAttribute("locale", locale.toString());
    httpServletRequest.setAttribute("localeRef", locale);
    httpServletRequest.setAttribute("messageSource", messageSource);
    return true;//from  w  w  w  .ja va2s  .c o  m
}