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:org.eg.sc.web.ShopCartAction.java

public String queryAllProduct() {
    List<Product> products = shoppingCartServiceImpl.queryAllProduct();
    HttpServletRequest request = ServletActionContext.getRequest();
    request.setAttribute("products", products);
    HttpSession session = ServletActionContext.getRequest().getSession();
    OrderCar car = (OrderCar) session.getAttribute("Car");
    if (car == null) {
        car = new OrderCar();
        session.setAttribute("Car", car);
    }//  w w w.j  a  va  2 s . co m

    return SUCCESS;
}

From source file:org.openregistry.core.web.ReferenceRepositoryHandlerInterceptor.java

@Override
public boolean preHandle(final HttpServletRequest request, final HttpServletResponse httpServletResponse,
        final Object o) throws Exception {
    request.setAttribute("countries", this.referenceRepository.getCountries());
    request.setAttribute("regions", this.referenceRepository.getRegions());
    request.setAttribute("campuses", this.referenceRepository.getCampuses());
    request.setAttribute("identifierTypes", this.referenceRepository.getIdentifierTypes());
    request.setAttribute("organizationalUnits", this.referenceRepository.getOrganizationalUnits());
    request.setAttribute("addressTypes", this.referenceRepository.getTypesBy(Type.DataTypes.ADDRESS));
    request.setAttribute("affiliationTypes", this.referenceRepository.getTypesBy(Type.DataTypes.AFFILIATION));
    request.setAttribute("campusTypes", this.referenceRepository.getTypesBy(Type.DataTypes.CAMPUS));
    request.setAttribute("nameTypes", this.referenceRepository.getTypesBy(Type.DataTypes.NAME));
    request.setAttribute("organizationalUnitTypes",
            this.referenceRepository.getTypesBy(Type.DataTypes.ORGANIZATIONAL_UNIT));
    request.setAttribute("personTypes", this.referenceRepository.getTypesBy(Type.DataTypes.PERSON));
    request.setAttribute("phoneTypes", this.referenceRepository.getTypesBy(Type.DataTypes.PHONE));
    request.setAttribute("sponsorTypes", this.referenceRepository.getTypesBy(Type.DataTypes.SPONSOR));
    request.setAttribute("statusTypes", this.referenceRepository.getTypesBy(Type.DataTypes.STATUS));
    request.setAttribute("terminationTypes", this.referenceRepository.getTypesBy(Type.DataTypes.TERMINATION));
    request.setAttribute("urlTypes", this.referenceRepository.getTypesBy(Type.DataTypes.URL));
    request.setAttribute("preferredPersonIdentifierType", this.preferredPersonIdentifierType);

    return true;//from   w  ww.  j a  v  a  2s  .  co m
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.manager.ManageHolidaysDA.java

@EntryPoint
public ActionForward prepare(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) {/* w  w w.  ja v a  2  s .  c  om*/
    final Set<Holiday> holidays = rootDomainObject.getHolidaysSet();
    request.setAttribute("holidays", holidays);
    return mapping.findForward("showHolidays");
}

From source file:com.netcracker.financeapp.controller.MainServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    int allMoney = bankCardService.getAllMoney();
    request.setAttribute("allMoney", allMoney);
    request.getRequestDispatcher("mainPage.jsp").forward(request, response);

}

From source file:org.sventon.appl.ConfigAuthorizationFilter.java

private void dispatchRequest(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
        throws IOException, ServletException {
    request.setAttribute("isEdit", true);
    filterChain.doFilter(request, response);
}

From source file:io.github.benas.todolist.web.servlet.user.RegisterServlet.java

private void addGlobalRegistrationErrorAttribute(HttpServletRequest request) {
    request.setAttribute("error", resourceBundle.getString("register.error.global"));
}

From source file:com.oddprints.servlets.EditPano.java

@POST
@Path("/basic")
@Produces(MediaType.TEXT_HTML)/*from w  ww  .  j  a  v  a  2 s . c  o  m*/
public Viewable doPost(@Context HttpServletRequest req)
        throws FileUploadException, IOException, URISyntaxException {
    Edit edit = new Edit();
    req.setAttribute("panoMode", Boolean.TRUE);
    // forward to normal servlet
    return edit.doPost(req);
}

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

/**
 * //from   ww w.ja va  2  s.c  o m
 **/
public ActionForward stepOne(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    request.setAttribute("isStatic", "true");
    return mapping.findForward("find.password.stepOne");
}

From source file:com.oddprints.servlets.EditPano.java

@GET
@Path("/basic/sample")
@Produces(MediaType.TEXT_HTML)/*from  w w  w.  j  a va  2 s . c  om*/
public Viewable loadBasicSample(@Context HttpServletRequest req)
        throws FileUploadException, IOException, URISyntaxException {
    Edit edit = new Edit();
    req.setAttribute("panoMode", Boolean.TRUE);
    // forward to normal servlet
    return edit.viewSampleImage(req, Settings.SAMPLE_PANO_BLOB_KEY, Settings.SAMPLE_PANO_BLOB_SIZE,
            new URL("http://www.oddprints.com/images/pano.jpg"));
}

From source file:org.shaigor.rest.retro.client.oauth.CustomOAuth2ClientContextFilter.java

@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain)
        throws IOException, ServletException {
    if (servletRequest instanceof HttpServletRequest) {
        HttpServletRequest request = ((HttpServletRequest) servletRequest);
        if (request.getAttribute(OAUTH2_REST_TEMPLATE) == null) {
            request.setAttribute(OAUTH2_REST_TEMPLATE, oauth2RestTemplate);
        }//from  w  ww  . ja v a2  s .c  o m
    }
    chain.doFilter(servletRequest, servletResponse);

}