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.bxf.hradmin.security.AccessDeniedHandler.java

@Override
public void handle(HttpServletRequest request, HttpServletResponse response,
        AccessDeniedException accessDeniedException) throws IOException, ServletException {

    request.setAttribute("defaultRedirectUrl", defaultRedirectUrl);
    request.setAttribute("timeToRedirect", timeToRedirect);

    RequestDispatcher dispatcher = request.getRequestDispatcher(errorPage);
    dispatcher.forward(request, response);
    return;// w  w  w  .j  a  va2  s  .c o  m
}

From source file:equipeDFK.sistemaX.controller.ControllerSession.java

/**
 * Mtodo que recebe uma requisio para autenticar um usurio no sistema
 * @param usuarioOuEmail//from   ww w .ja v  a2s. co  m
 * @param senha 
 * @param req 
 * @return  
 * @throws java.sql.SQLException  
 */
@RequestMapping("logar")
public String login(String usuarioOuEmail, String senha, HttpServletRequest req) throws SQLException {
    GerenciadorDeUsuario gu = new GerenciadorDeUsuario();
    Usuario u = gu.logar(usuarioOuEmail, senha);

    if (u == null) {
        req.setAttribute("erro", "Usurio ou senha invlidos");
        return "index";
    }
    req.getSession().setAttribute("usuarioLogado", u);
    return "home";
}

From source file:psiprobe.controllers.DecoratorController.java

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    try {//from  w w w .  j  av a 2s  .c o m
        request.setAttribute("hostname", InetAddress.getLocalHost().getHostName());
    } catch (UnknownHostException e) {
        request.setAttribute("hostname", "unknown");
        logger.trace("", e);
    }

    Properties version = (Properties) getApplicationContext().getBean("version");
    request.setAttribute("version", version.getProperty("probe.version"));

    long uptimeStartValue = ManagementFactory.getRuntimeMXBean().getStartTime();
    long uptime = System.currentTimeMillis() - uptimeStartValue;
    long uptimeDays = uptime / (1000 * 60 * 60 * 24);

    uptime = uptime % (1000 * 60 * 60 * 24);
    long uptimeHours = uptime / (1000 * 60 * 60);

    uptime = uptime % (1000 * 60 * 60);
    long uptimeMins = uptime / (1000 * 60);

    request.setAttribute("uptime_days", uptimeDays);
    request.setAttribute("uptime_hours", uptimeHours);
    request.setAttribute("uptime_mins", uptimeMins);
    //
    // Work out the language of the interface by matching resource files that we have
    // to the request locale.
    //
    String lang = "en";
    for (String fileName : getMessageFileNamesForLocale(request.getLocale())) {
        if (getServletContext().getResource(fileName + ".properties") != null) {
            lang = fileName.substring(messagesBasename.length() + 1);
            break;
        }
    }

    request.setAttribute("lang", lang);

    return super.handleRequestInternal(request, response);
}

From source file:net.duckling.ddl.web.controller.BaseController.java

/**
 * ?404/*  ww w  .ja  v a 2s  .com*/
 * @param request   HttpRequest
 * @param response   HttpResponse
 * @param inTeam   true??false???
 */
protected void notFound(HttpServletRequest request, HttpServletResponse response, boolean inTeam) {
    if (!inTeam) {
        request.setAttribute("accessMain", Boolean.TRUE);
    }
    try {
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
    } catch (IOException e) {
        LOGGER.debug("Error founded in not found :", e);
    }
}

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

public ActionForward prepareManageLoginTimeIntervals(ActionMapping mapping, ActionForm actionForm,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    Person person = getPersonFromParameter(request);
    request.setAttribute("person", person);
    return mapping.findForward("prepareManageLoginTimeIntervals");
}

From source file:org.eg.sc.web.TempAction.java

@Override
public String execute() {
    HttpServletRequest request = ServletActionContext.getRequest();
    List<Product> products = shoppingCartServiceImpl.queryAllProduct();
    request.getSession().setAttribute("User", null);
    request.setAttribute("products", products);
    request.getSession().setAttribute("Car", null);
    return SUCCESS;
}

From source file:com.forsrc.springmvc.restful.base.validator.Validator.java

/**
 * Sets message.// www  .j  a  v  a  2s  . c  o m
 *
 * @param request the request
 * @param key     the key
 * @param msg     the msg
 */
protected void setMessage(HttpServletRequest request, String key, String msg) {
    request.setAttribute(key, msg);
}

From source file:de.hybris.platform.b2bpunchoutaddon.controllers.pages.DefaultPunchOutController.java

@ExceptionHandler(Exception.class)
public String handleException(final Exception e, final HttpServletRequest request) {
    LOG.error(e.getMessage(), e);// w ww .java 2s . com
    request.setAttribute("error", e);
    request.setAttribute("message", PunchOutException.PUNCHOUT_EXCEPTION_MESSAGE);

    return ADDON_PREFIX + BASE_ADDON_PAGE_PATH + "/error/punchoutError";
}

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

public ActionForward viewVigilants(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) {/*  w w w . j a  v  a 2s  .  com*/
    setState(request);
    request.setAttribute("unconvokeRequest", new VariantBean());
    return doForward(request, "/teacher/evaluation/vigilancies/viewVigilancies.jsp");
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.messaging.ViewSentEmailsDA.java

public ActionForward viewSentEmails(final ActionMapping mapping, final HttpServletRequest request,
        final Sender sender) {
    request.setAttribute("sender", sender);
    return mapping.findForward("view.sent.emails");
}