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:cz.metacentrum.perun.oidc.overlay.PerunConfigInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
    request.setAttribute("perunConfig", perunConfig);
    return true;/*  www  .  jav a  2 s .co m*/
}

From source file:org.jutge.joc.porra.controller.mobile.MobileHomeController.java

@ExceptionHandler(PorraException.class)
public String exceptionHandler(PorraException exception, HttpServletRequest request) {
    this.logger.info("MobileHomeController.exceptionHandler");
    request.setAttribute("errorMessages", exception.getErrorMessages());
    return "/mobile/error";
}

From source file:ui.controller.ControllerParent.java

public boolean authenticated(HttpServletRequest request) {
    User u = (User) request.getSession().getAttribute("User");
    request.setAttribute("user", u);
    return u != null;
}

From source file:org.mitre.openid.connect.web.ServerConfigInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
    request.setAttribute("config", config);
    return true;/*from w w  w.  ja v a  2s  .c  om*/
}

From source file:dijalmasilva.controllers.LugarController.java

@RequestMapping("/new")
public String newLugar(LugarForm l, HttpServletRequest req) {

    if (l == null) {
        req.setAttribute("result", "Algum dado inserido est invlido.");
    } else {/*w w w .  j a  va 2s .  c om*/
        Usuario usuarioLogado = (Usuario) req.getSession().getAttribute("usuarioLogado");
        Lugar newPlace = service.salvar(l.convertToLugar(), usuarioLogado);
        if (newPlace != null) {
            List<Lugar> todasOcorrencias = service.buscarTodos();
            req.getServletContext().setAttribute("todasOcorrencias", todasOcorrencias);
            req.setAttribute("result", "Ocorrncia registrada com sucesso!");
        } else {
            req.setAttribute("result",
                    "No foi possvel registrar a ocorrncia. \n Tente novamente mais tarde.!");
        }
    }

    return "home";
}

From source file:gallery.web.controller.cms.IndexCmsController.java

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    request.setAttribute("content_url", content_url);
    request.setAttribute("navigation_url", navigation_url);
    request.setAttribute("title", "? ?? ?");
    request.setAttribute("top_header", "? ?? ?");
    return new ModelAndView(config.getTemplateUrl());
}

From source file:com.nec.harvest.servlet.interceptor.LoggerInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
    request.setAttribute(STRAT_EXECUTION_TIME_KEY, System.currentTimeMillis());
    return super.preHandle(request, response, handler);
}

From source file:info.magnolia.cms.filters.MultipartRequestFilter.java

/**
 * Adds all request paramaters as request attributes.
 * @param request HttpServletRequest/*from w  w  w  .  j  av  a2s . c  o m*/
 */
private static void parseParameters(HttpServletRequest request) throws IOException {
    MultipartForm form = new MultipartForm();
    String encoding = StringUtils.defaultString(request.getCharacterEncoding(), "UTF-8"); //$NON-NLS-1$
    MultipartRequest multi = new MultipartRequest(request, Path.getTempDirectoryPath(), MAX_FILE_SIZE, encoding,
            null);
    Enumeration params = multi.getParameterNames();
    while (params.hasMoreElements()) {
        String name = (String) params.nextElement();
        String value = multi.getParameter(name);
        form.addParameter(name, value);
        String[] s = multi.getParameterValues(name);
        if (s != null) {
            form.addparameterValues(name, s);
        }
    }
    Enumeration files = multi.getFileNames();
    while (files.hasMoreElements()) {
        String name = (String) files.nextElement();
        form.addDocument(name, multi.getFilesystemName(name), multi.getContentType(name), multi.getFile(name));
    }
    request.setAttribute(MultipartForm.REQUEST_ATTRIBUTE_NAME, form);
}

From source file:com.github.lynxdb.server.api.http.Interceptor.java

@Override
public boolean preHandle(HttpServletRequest _request, HttpServletResponse _response, Object _handler) {
    _request.setAttribute("startTime", System.currentTimeMillis());
    return true;// w  w  w .j av  a  2 s .co m
}

From source file:uk.ac.ox.oucs.vle.mvc.CourseDispatcherServlet.java

/**
 * this is overridden to ensure that the Native URL is present.
 */// w w w  .  j a  va 2s  .co m
@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    request.setAttribute(Tool.NATIVE_URL, Tool.NATIVE_URL);
    try {
        super.service(request, response);
    } finally {
        request.removeAttribute(Tool.NATIVE_URL);
    }

}