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:edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerComponentGenerator.java

FreemarkerComponentGenerator(HttpServletRequest request) {

    // Mimic what FreemarkerHttpServlet does for a new request
    VitroRequest vreq = new VitroRequest(request);
    Map<String, Object> map = getPageTemplateValues(vreq);

    request.setAttribute("ftl_head", getHead("head", map, vreq));
    request.setAttribute("ftl_identity", get("identity", map, vreq));
    request.setAttribute("ftl_menu", get("menu", map, vreq));
    request.setAttribute("ftl_search", get("search", map, vreq));
    request.setAttribute("ftl_footer", get("footer", map, vreq));
    request.setAttribute("ftl_googleAnalytics", get("googleAnalytics", map, vreq));
}

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

public ActionForward findPerson(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    String name = getStringFromRequest(request, "name");
    request.setAttribute("name", name);

    String email = getStringFromRequest(request, "email");
    request.setAttribute("email", email);

    String username = getStringFromRequest(request, "username");
    request.setAttribute("username", username);

    String documentIdNumber = getStringFromRequest(request, "documentIdNumber");
    request.setAttribute("documentIdNumber", documentIdNumber);

    String mechanoGraphicalNumber = getStringFromRequest(request, "mechanoGraphicalNumber").replace(" ", "");
    request.setAttribute("mechanoGraphicalNumber", mechanoGraphicalNumber);

    if (!Strings.isNullOrEmpty(mechanoGraphicalNumber) && Ints.tryParse(mechanoGraphicalNumber) == null) {
        addActionMessage(request, "error.mechanoGraphicalNumber",
                getStringFromRequest(request, "mechanoGraphicalNumber"));
        return prepareFindPerson(mapping, actionForm, request, response);
    }//from   w ww. j  a va2s  .c o m

    SearchParameters searchParameters = new SearchPerson.SearchParameters(name, email, username,
            documentIdNumber, null, null, null, null, null, null, null, null, (String) null);

    if ((mechanoGraphicalNumber != null) && (mechanoGraphicalNumber.length() > 0)) {
        searchParameters.setMechanoGraphicalNumber(Integer.parseInt(mechanoGraphicalNumber));
    }

    SearchPersonPredicate predicate = new SearchPerson.SearchPersonPredicate(searchParameters);

    CollectionPager<Person> result = SearchPerson.runSearchPerson(searchParameters, predicate);

    final String pageNumberString = request.getParameter("pageNumber");
    final Integer pageNumber = !StringUtils.isEmpty(pageNumberString) ? Integer.valueOf(pageNumberString)
            : Integer.valueOf(1);
    request.setAttribute("pageNumber", pageNumber);
    request.setAttribute("numberOfPages", Integer.valueOf(result.getNumberOfPages()));
    request.setAttribute("personListFinded", result.getPage(pageNumber.intValue()));
    request.setAttribute("totalFindedPersons", result.getCollection().size());

    return mapping.findForward("displayPerson");
}

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

public ActionForward viewCourses(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) {//from   w  w  w .ja  va2  s  .c o  m

    ScientificAreaUnit scientificArea = (ScientificAreaUnit) getUnit(request);

    request.setAttribute("courseGroupUnits", scientificArea.getCompetenceCourseGroupUnits());

    return mapping.findForward("view-courses");
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.phd.candidacy.publicProgram.PublicPhdProgramCandidacyProcessDA.java

@Override
public ActionForward execute(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    request.setAttribute("sibsEntityCode", SIBS_ENTITY_CODE);

    request.setAttribute("dont-cache-pages-in-search-engines", Boolean.TRUE);

    final PhdProgramCandidacyProcessBean bean = getCandidacyBean();
    if (bean != null && bean.hasCandidacyHashCode()) {
        canEditCandidacy(request, bean.getCandidacyHashCode());
    }/*  w  w w  . ja  v  a  2 s.  c o m*/

    ActionForward forward = filterDispatchMethod(bean, mapping, actionForm, request, response);

    if (forward != null) {
        return forward;
    }

    //TODO remove this when public sites portalization is complete
    request.setAttribute(Globals.LOCALE_KEY, I18N.getLocale());
    request.getSession().setAttribute(Globals.LOCALE_KEY, I18N.getLocale());

    return super.execute(mapping, actionForm, request, response);
}

From source file:com.netcracker.financeapp.controller.income.IncomeServlet.java

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

    ArrayList<String> bankCardNumbers = bankCardService.getBankCardNumbers();
    request.setAttribute("toList", bankCardNumbers);

    ArrayList<String> agentNames = agentService.getAgentNames();
    request.setAttribute("fromList", agentNames);

    request.getRequestDispatcher("income/incomePage.jsp").forward(request, response);

}

From source file:common.cms.controller.ACmsDelegate.java

/**
 * must show items associated with this table
 * that matches given criteria//from   w ww  . j ava 2  s  .  c o  m
 * @param req
 * @param resp
 * @return
 */
public ModelAndView doFilteredView(HttpServletRequest req, HttpServletResponse resp) {
    getCommonModel(req);
    req.setAttribute(config.getContentUrlAttribute(), config.getContentViewTemplate());

    CommonActions.doFilteredSelect(filterService, config, filterValidator, req);

    return new ModelAndView(config.getTemplateUrl());
}

From source file:web.KategoriServlet.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*from ww w. j av a2s.  com*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    EntityManager em = emf.createEntityManager();
    KategoriDAO dao = new KategoriDAOImpl(em);
    request.setAttribute("kategoris", dao.getAll());
    RequestDispatcher rd = request.getRequestDispatcher("daftar_kategori.jsp");
    rd.forward(request, response);
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.teacher.SearchExecutionCourseAttendsAction.java

public ActionForward search(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) {//from   w ww  .ja  v a 2s .c  om

    request.setAttribute("objectCode", request.getAttribute("objectCode"));

    SearchExecutionCourseAttendsBean bean = getRenderedObject();
    RenderUtils.invalidateViewState();
    bean.getExecutionCourse().searchAttends(bean);

    request.setAttribute("searchBean", bean);
    request.setAttribute("executionCourse", bean.getExecutionCourse());

    prepareAttendsCollectionPages(request, bean, bean.getExecutionCourse());

    return forward(request, "/teacher/viewAttendsSearch.jsp");
}

From source file:common.cms.controller.ACmsDelegate.java

/**
 * inserts a row into db ...//from www.  j a  va2s.co  m
 * @param req
 * @param resp
 * @return
 */
public ModelAndView doInsert(HttpServletRequest req, HttpServletResponse resp) {
    getCommonModel(req);
    req.setAttribute("editForm_topHeader", "");
    req.setAttribute(config.getContentUrlAttribute(), config.getContentInsertTemplate());

    CommonActions.doInsert(insertService, config, insertValidator, req);

    return new ModelAndView(config.getTemplateUrl());
}

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

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    request.setAttribute("registerTabStyle", "active");
    request.getRequestDispatcher(REGISTER_PAGE).forward(request, response);
}