Example usage for javax.servlet.http HttpSession setAttribute

List of usage examples for javax.servlet.http HttpSession setAttribute

Introduction

In this page you can find the example usage for javax.servlet.http HttpSession setAttribute.

Prototype

public void setAttribute(String name, Object value);

Source Link

Document

Binds an object to this session, using the name specified.

Usage

From source file:be.fedict.eid.applet.service.signer.HttpSessionTemporaryDataStorage.java

public OutputStream getTempOutputStream() {
    LOG.debug("get new temp output stream");
    HttpSession httpSession = getHttpSession();
    ByteArrayOutputStream tempOutputStream = new ByteArrayOutputStream();
    httpSession.setAttribute(TEMP_OUTPUT_STREAM_ATTRIBUTE, tempOutputStream);
    return tempOutputStream;
}

From source file:org.openmrs.module.radiology.web.controller.main.MainController.java

@RequestMapping(method = RequestMethod.GET)
public String firstView(HttpServletRequest request, Model model) {

    HttpSession session = request.getSession();
    Map<Concept, Set<Concept>> testTreeMap = generateTestTreeMap();
    System.out.println("testTreeMap ===> " + testTreeMap);
    session.setAttribute(RadiologyConstants.SESSION_TEST_TREE_MAP, testTreeMap);

    return "/module/radiology/main/main";
}

From source file:svc.managers.SMSManagerTest.java

private void setStageInSession(HttpSession session, SMS_STAGE textStage) {
    session.setAttribute("stage", new Integer(textStage.getNumVal()));
}

From source file:io.seldon.api.interceptor.GenericScopedInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
    final String requestURI = request.getRequestURI();
    if (logger.isDebugEnabled())
        logger.debug("Scoped interceptor for: " + requestURI);
    Date start = new Date();
    request.setAttribute("startTime", start);
    try {//from ww  w. j av  a2  s .co m
        final ConsumerBean consumerBean = authorise(request);
        final HttpSession session = request.getSession();
        session.setAttribute("consumer", consumerBean);
        return super.preHandle(request, response, handler);
    } catch (APIException e) {
        exceptionResponse(request, response, e);
        String apiKey = request.getServletPath().replaceAll("/", "\\."); //Asumes no user/item ids in path!!!!
        ApiLogger.log(apiKey, start, request, null);
    } catch (Throwable t) {
        logger.error("GenericScopedInterceptor#preHandle: " + t.getMessage(), t);
    }
    return false;
}

From source file:org.openmrs.module.idcards.web.controller.GenerateIdentifiersFormController.java

/**
 * Handles the user's submission of the form.
 */// www .j  a  va2 s  .  c  o  m
@RequestMapping(method = RequestMethod.POST, value = "/module/idcards/generateIdentifiers")
public String onSubmit(@RequestParam Integer initialMrn, @RequestParam Integer mrn_count,
        HttpSession httpSession) {

    IdcardsService service = (IdcardsService) Context.getService(IdcardsService.class);
    service.generateIdentifiers(initialMrn, mrn_count);

    httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR,
            "Identifiers generated successfully at : " + new Date());

    return "redirect:/module/idcards/generateIdentifiers.form";
}

From source file:org.wso2.carbon.la.restapi.LoginLogoutApiV10.java

/**
 * Login/* ww w  .j  a v a  2 s  .  co m*/
 */
@POST
@Path("/login")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response login() {
    //create session if not found
    HttpSession httpSession = httpServletRequest.getSession();
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    httpSession.setAttribute("userName", carbonContext.getUsername());
    httpSession.setAttribute("tenantDomain", carbonContext.getTenantDomain());
    httpSession.setAttribute("tenantId", carbonContext.getTenantId());
    //String sessionId = httpSession.getId();
    return Response.status(Response.Status.OK).entity("User logged in: " + carbonContext.getUsername()).build();
}

From source file:it.jugpadova.controllers.EventEditController.java

@RequestMapping(value = "/event/cleanSession.form", method = RequestMethod.GET)
public String cleanEventSession(HttpSession session) {
    clearSpeakerSession(session);// ww  w.  jav a  2s. c o m
    session.setAttribute("event", null);
    return "redirect:/";
}

From source file:cc.kune.core.server.UserSessionManagerImpl.java

@Override
public void login(final Long userId, final String newUserHash) {
    final HttpSession session = getSession();
    session.setAttribute(USER_ID, userId);
    session.setAttribute(USER_HASH, newUserHash);
}

From source file:com.flexive.war.filter.SessionFixationFilter.java

private void setAttributes(HttpSession session, Map<String, Object> attributes) {
    for (Map.Entry<String, Object> entry : attributes.entrySet()) {
        session.setAttribute(entry.getKey(), entry.getValue());
    }//from  w  w  w  .  j  a  va  2  s .  c o m
}

From source file:cc.kune.core.server.UserSessionManagerImpl.java

@Override
public void logout() {
    final HttpSession session = getSession();
    session.setAttribute(USER_ID, null);
    session.setAttribute(USER_HASH, null);
    waveSessionManager.logout(session);/*from  w w  w  .j a va2  s .co m*/
}