Example usage for javax.servlet.http HttpServletRequest getAttribute

List of usage examples for javax.servlet.http HttpServletRequest getAttribute

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getAttribute.

Prototype

public Object getAttribute(String name);

Source Link

Document

Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.

Usage

From source file:com.acc.storefront.security.AcceleratorRememberMeServices.java

protected String getUrlEncodingPattern(final HttpServletRequest request) {
    final String encodingAttributes = (String) request.getAttribute(WebConstants.URL_ENCODING_ATTRIBUTES);
    return StringUtils.defaultString(encodingAttributes);
}

From source file:org.atmosphere.samples.pubsub.spring.PubSubController.java

/**
 * This method takes a request to subscribe to the topic
 * /*  w  ww .j a va  2  s.c  o  m*/
 * @param request
 * @return ModelAndView
 */
@RequestMapping(value = "{topic}", method = RequestMethod.GET)
public ModelAndView subscribe(HttpServletRequest request) throws Exception {
    AtmosphereResource resource = (AtmosphereResource) request
            .getAttribute(FrameworkConfig.ATMOSPHERE_RESOURCE);

    this.doGet(resource, request, resource.getResponse());

    // A NoOpView is returned to tell Spring Dispatcher framework not to render anything
    // since it is all Atmosphere-related code
    ModelAndView mv = new ModelAndView(new NoOpView());
    return mv;
}

From source file:com.adito.properties.attributes.actions.AttributeDefinitionInformationAction.java

/**
 * Display information about an attribute definition
 * /*w ww . j a v  a  2  s.  com*/
 * @param mapping mapping
 * @param form form
 * @param request request
 * @param response response
 * @return forward
 * @throws Exception on any error
 */
public ActionForward attributeInformation(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    AttributeDefinition def = (AttributeDefinition) request.getAttribute(Constants.REQ_ATTR_INFO_RESOURCE);
    MessageResources mr = null;
    if (def.getMessageResourcesKey() != null) {
        mr = CoreUtil.getMessageResources(request.getSession(), def.getMessageResourcesKey());
    }
    Locale locale = (Locale) request.getSession().getAttribute(Globals.LOCALE_KEY);
    ((AttributeDefinitionInformationForm) form).initialise(mr, def, locale);
    return mapping.findForward("display");
}

From source file:cn.cug.laboratory.web.BaseController.java

/**
 *  HttpServletRequest ?/*w w  w.ja va2 s  .  c o m*/
 * @param name
 * @return
 */
protected Object getHttpServletRequestAttribute(String name) {
    HttpServletRequest request = this.getHttpServletRequest();
    Object value = request.getAttribute(name);
    return value;
}

From source file:org.atmosphere.samples.pubsub.PubSubController.java

private void processPost(String topic, HttpServletRequest req, AtmosphereResource resource) throws IOException {

    String restOfTheUrl = (String) req.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);

    Broadcaster b = lookupBroadcaster(topic, restOfTheUrl);

    String message = req.getReader().readLine();
    resource.resume();/*from  w  w  w. j av a 2 s  .  com*/
    if (message != null && message.indexOf("message") != FORE_EVER) {
        b.broadcast(message.substring("message=".length()));
    }
}

From source file:org.cloudfoundry.identity.uaa.home.HomeController.java

@RequestMapping("/error500")
public String error500(Model model, HttpServletRequest request) {
    logger.error("Internal error", (Throwable) request.getAttribute("javax.servlet.error.exception"));

    populateBuildAndLinkInfo(model);//www.  j  av a 2 s  .c  o  m
    return "error";
}

From source file:com.opencart.controller.AdminController.java

@RequestMapping(value = "/admin/appconf", method = RequestMethod.POST)
public ModelAndView showAppConfigPost(HttpServletRequest request, HttpServletResponse response) {

    //Action can be either add or update
    String action = (String) request.getAttribute("action");

    ModelAndView mv = new ModelAndView("admin/app_config?action=showone");
    return mv;//from   w  w  w .  jav a2  s . c  om
}

From source file:io.druid.server.AsyncManagementForwardingServlet.java

@Override
protected String rewriteTarget(HttpServletRequest request) {
    try {/*from  w ww .  j a v a  2 s  . c o m*/
        return new URIBuilder((String) request.getAttribute(BASE_URI_ATTRIBUTE))
                .setPath(request.getAttribute(MODIFIED_PATH_ATTRIBUTE) != null
                        ? (String) request.getAttribute(MODIFIED_PATH_ATTRIBUTE)
                        : request.getRequestURI())
                .setQuery(request.getQueryString()) // No need to encode-decode queryString, it is already encoded
                .build().toString();
    } catch (URISyntaxException e) {
        log.error(e, "Unable to rewrite URI [%s]", e.getMessage());
        throw Throwables.propagate(e);
    }
}

From source file:com.pkrete.locationservice.admin.controller.rest.v1.MyAccountRestController.java

@RequestMapping(method = RequestMethod.GET, produces = "application/json; charset=utf-8")
@ResponseBody//w ww.j a  v  a2  s .co m
public Map index(HttpServletRequest request) throws ResourceNotFoundException {
    // Get operator id
    String operator = (String) request.getAttribute("operator");
    // Get UserInfo matching the given operator
    UserInfo user = this.service.getUserInfoByUsername(operator);
    // Check for null value
    if (user == null) {
        // Throw exception
        throw new ResourceNotFoundException(getMessage("rest.resource.not.exist"));
    }
    // Return the userwww
    return this.mapConverter.convert(user);
}

From source file:com.jaspersoft.jasperserver.war.control.SystemErrorController.java

/**
 * Handles 500 error (page not found error).
 *
 * @param req the request.//from  w w w.j av a  2  s.  com
 * @param res the response.
 *
 * @return model and view.
 */
public ModelAndView handle500(HttpServletRequest req, HttpServletResponse res) {
    ModelAndView mav = new ModelAndView("modules/system/500");

    String systemErrorDetails = (String) req.getAttribute("javax.servlet.error.message");

    Object e = req.getAttribute("javax.servlet.error.exception");

    if (e != null && e instanceof Throwable) {
        logger.error("Internal server error", (Throwable) e);
        if (systemErrorDetails == null || systemErrorDetails.length() == 0)
            systemErrorDetails = ((Throwable) e).getMessage();
    }

    mav.addObject("systemErrorDetails", systemErrorDetails);
    return mav;
}