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:com.mkmeier.quickerbooks.ProcessUwcu.java

private void showForm(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    Map<String, List<QbAccount>> accountLists = getAccountLists();

    HttpSession session = request.getSession(true);
    session.setAttribute("lists", accountLists);

    RequestDispatcher rd = request.getRequestDispatcher("UwcuProcessor.jsp");
    rd.forward(request, response);//from www  .  j  av a  2s .  c o m
}

From source file:org.openmrs.web.controller.concept.ConceptStopWordListController.java

/**
 * This method to load all the Concept Stop Words in the request attribute and return the
 * ConceptStopWordList view//from www . java2  s. c  o m
 * 
 * @param session http session
 * @return ConceptStopWordList view
 * @should return Concept Stop Word List View
 * @should add all ConceptStopWords in session attribute
 */
@RequestMapping(method = RequestMethod.GET)
public String showForm(HttpSession session) {

    ConceptService conceptService = Context.getConceptService();
    List<ConceptStopWord> conceptStopWordList = conceptService.getAllConceptStopWords();
    session.setAttribute("conceptStopWordList", conceptStopWordList);

    return "admin/concepts/conceptStopWordList";
}

From source file:nl.surfnet.mujina.saml.RealAssertionConsumer.java

@Override
public User consume(Response samlResponse) throws AuthenticationException {

    try {//  w w  w .  jav a  2  s .  co  m
        validatorSuite.validate(samlResponse);
    } catch (ValidationException ve) {
        log.warn("Response Message failed Validation", ve);
        throw new ServiceProviderAuthenticationException("Invalid SAML REsponse Message", ve);
    }

    checkResponseStatus(samlResponse);

    Assertion assertion = samlResponse.getAssertions().get(0);

    log.debug("authenticationResponseIssuingEntityName {}", samlResponse.getIssuer().getValue());

    log.debug("assertion.getID() {}", assertion.getID());
    log.debug("assertion.getSubject().getNameID().getValue() {}",
            assertion.getSubject().getNameID().getValue());

    AuthnStatement authnStatement = assertion.getAuthnStatements().get(0);

    log.debug("authnStatement.getAuthnInstant() {}", authnStatement.getAuthnInstant());

    Set<GrantedAuthority> authorities = extractAuthorities(assertion.getAttributeStatements());
    log.debug("Granted Authorities will be {}", authorities);

    final ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder
            .currentRequestAttributes();
    final HttpSession session = requestAttributes.getRequest().getSession();
    session.setAttribute("assertionAttributes", assertion.getAttributeStatements());

    log.debug("assertion.getID() {}", assertion.getAuthnStatements());

    return new User(assertion.getSubject().getNameID().getValue(), samlResponse.getIssuer().getValue(),
            assertion.getIssuer().getValue(), samlResponse.getID(), assertion.getID(),
            samlResponse.getIssueInstant(), assertion.getIssueInstant(), authnStatement.getAuthnInstant(),
            authorities);

}

From source file:org.openmrs.module.amrsmobileforms.web.controller.SyncLogController.java

@RequestMapping(value = "/module/amrsmobileforms/syncLog", method = RequestMethod.POST)
public String changeLogDate(HttpSession httpSession, @RequestParam String logDate) {
    if (logDate.trim().length() > 0) {
        try {// w  w w.j a  v  a2  s . co  m
            syncLogDate = df.parse(logDate);
        } catch (ParseException e) {
            httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "Invalid date format");
            e.printStackTrace();
        }
    } else
        httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "No Date selected");
    return "redirect:syncLog.list";
}

From source file:com.tsg.cms.StaticPageController.java

@RequestMapping(value = "/pageTinyMCE/{id}", method = RequestMethod.GET)
public String showPopulatedEditor(@PathVariable("id") int id, Map<String, Object> model, HttpSession session) {

    //model.put("staticPage", dao.getStaticPageById(id));
    session.setAttribute("page", "pageTinyMCE");

    session.setAttribute("js_page", "pageTinyMCE.js");

    model.put("editStaticPageId", id);
    return "home";
}

From source file:per.mnn.controller.CartController.java

private ShoppingCart checkCart(HttpServletRequest request) {

    HttpSession httpSess = request.getSession();
    ShoppingCart cart = (ShoppingCart) httpSess.getAttribute("cart");
    if (cart == null) {
        cart = new ShoppingCart();
        httpSess.setAttribute("cart", cart);
    }//from   ww  w.j a  v a  2s. c  o  m

    return cart;
}

From source file:edu.caltechUcla.sselCassel.projects.jMarkets.frontdesk.web.actions.EditSessionConfigAction.java

/**
 * Process the specified HTTP request, and create the corresponding HTTP
 * response (or forward to another web component that will create it).
 * Return an <code>ActionForward</code> instance describing where and how
 * control should be forwarded, or <code>null</code> if the response has
 * already been completed.// w  w w.jav  a 2 s.c o  m
 *
 * @param mapping The ActionMapping used to select this instance
 * @param actionForm The optional ActionForm bean for this request (if any)
 * @param request The HTTP request we are processing
 * @param response The HTTP response we are creating
 *
 * @exception Exception if the application business logic throws
 *  an exception
 */
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    // Extract attributes we will need
    HttpSession session = request.getSession();

    if ("request".equals(mapping.getScope())) {
        request.setAttribute(mapping.getAttribute(), form);
    } else {
        session.setAttribute(mapping.getAttribute(), form);
    }

    DynaValidatorForm expForm = (DynaValidatorForm) form;

    if (!isExperimenter(session))
        return (mapping.findForward("login_fail"));
    else
        return (mapping.findForward("success"));
}

From source file:egpi.tes.ahv.servicio.AutenticacionREST.java

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    try {/*from   ww  w .j av  a2 s . c o  m*/

        HttpSession session = request.getSession(true);
        session.setAttribute("clientjasper", this.client);
        session.setAttribute("propiedadesjasper", this.properties);
        session.removeAttribute("authVO");

        autenticacionUsuarioGeneral();

        PrintWriter out = response.getWriter();
        out.println(obj);

    } catch (Exception e) {
        e.printStackTrace();
        procesarError(response, e);
    }

}

From source file:contestWebsite.ContactUs.java

@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    VelocityEngine ve = new VelocityEngine();
    ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, "html/pages, html/snippets");
    ve.init();/*from  www  .  ja v a 2 s . c o m*/
    VelocityContext context = new VelocityContext();
    Pair<Entity, UserCookie> infoAndCookie = init(context, req);

    UserCookie userCookie = infoAndCookie.y;
    boolean loggedIn = (boolean) context.get("loggedIn");
    Entity user = userCookie != null ? userCookie.authenticateUser() : null;

    HttpSession sess = req.getSession(true);
    sess.setAttribute("nocaptcha", loggedIn && !userCookie.isAdmin());

    if (loggedIn && !userCookie.isAdmin()) {
        context.put("user", user.getProperty("user-id"));
        context.put("name", user.getProperty("name"));
        context.put("email", user.getProperty("user-id"));
        context.put("school", user.getProperty("school"));
    } else {
        context.put("email", sess.getAttribute("email"));
        context.put("name", sess.getAttribute("name"));
        context.put("school", sess.getAttribute("school"));
        context.put("comment", sess.getAttribute("comment"));
    }

    if (req.getParameter("comment") != null) {
        context.put("comment", req.getParameter("comment"));
    }

    context.put("captchaError", req.getParameter("captchaError"));
    context.put("nocaptcha", loggedIn && !userCookie.isAdmin());
    context.put("updated", req.getParameter("updated"));
    context.put("admin", userCookie != null && userCookie.isAdmin());
    context.put("publicKey", infoAndCookie.x.getProperty("publicKey"));

    close(context, ve.getTemplate("contactUs.html"), resp);
}

From source file:com.wx.spring.controller.OAuth2Controller.java

/** 
 * ?code?Userid???? //  w  w  w .jav  a 2  s  .  com
 *  
 * @param request 
 * @param code 
 *            ???URLcode? 
 * @param oauth2url 
 *            ?? 
 * @return 
 */
@RequestMapping(value = { "/oauth2url.do" })
public String Oauth2MeUrl(HttpServletRequest request, @RequestParam String code,
        @RequestParam String oauth2url) {

    HttpSession session = request.getSession();

    String Userid = getMemberGuidByCode(AccessTokenGen.GetToken(), code, 1);
    if (Userid != null) {
        session.setAttribute("UserId", Userid);
    }

    // ??,session  
    return "redirect:" + oauth2url;
}