Example usage for javax.servlet.http HttpServletRequest getSession

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

Introduction

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

Prototype

public HttpSession getSession();

Source Link

Document

Returns the current session associated with this request, or if the request does not have a session, creates one.

Usage

From source file:com.pureinfo.tgirls.utils.servlet.CookieUtils.java

public static Object getRequestCookieValue(HttpServletRequest request, String key) {
    Object value = request.getSession().getAttribute(key);
    if (value != null) {
        return value;
    }/*from  ww  w .j  a va2s .  c om*/
    return getCookieValue(request.getCookies(), key);
}

From source file:com.orchestra.portale.utils.InsertUtils.java

public static String delimg(HttpServletRequest request, String id, String nameimg) {
    String esito = "";
    HttpSession session = request.getSession();
    ServletContext sc = session.getServletContext();
    File dir = new File(sc.getRealPath("/") + "dist" + File.separator + "poi" + File.separator + "img"
            + File.separator + id);

    File img = new File(dir.getAbsolutePath() + File.separator + nameimg);
    if (img.delete())
        esito = "OK";
    else/*from   ww w. j a v a2s  . com*/
        esito = "ERRORE";

    return esito;
}

From source file:org.keycloak.example.CustomerDatabaseClient.java

public static String increaseAndGetCounter(HttpServletRequest req) {
    HttpSession session = req.getSession();
    Integer counter = (Integer) session.getAttribute("counter");
    counter = (counter == null) ? 1 : counter + 1;
    session.setAttribute("counter", counter);
    return String.valueOf(counter);
}

From source file:eionet.gdem.web.struts.qascript.QAScriptListLoader.java

public static void clearList(HttpServletRequest httpServletRequest) {
    httpServletRequest.getSession().getServletContext().removeAttribute(QASCRIPT_LIST_ATTR);
}

From source file:eionet.gdem.web.struts.qascript.QAScriptListLoader.java

public static void clearPermissions(HttpServletRequest httpServletRequest) {
    httpServletRequest.getSession().removeAttribute(QASCRIPT_PERMISSIONS_ATTR);
}

From source file:com.jsquant.listener.JsquantContextListener.java

public static FileCache getFileCache(HttpServletRequest request) {
    return getFileCache(request.getSession().getServletContext());
}

From source file:com.netease.channel.util.LoginUtil.java

public static String getSessionLoginStatus(final HttpServletRequest request) {
    return (String) request.getSession().getAttribute(SESSION_USER_NAME);
}

From source file:com.jsquant.listener.JsquantContextListener.java

public static HttpClient getHttpClient(HttpServletRequest request) {
    return getHttpClient(request.getSession().getServletContext());
}

From source file:alfio.controller.support.SessionUtil.java

public static void saveSpecialPriceCode(String specialPriceCode, HttpServletRequest request) {
    if (StringUtils.isNotEmpty(specialPriceCode)) {
        request.getSession().setAttribute(SPECIAL_PRICE_CODE_SESSION_ID, UUID.randomUUID().toString());
        request.getSession().setAttribute(SPECIAL_PRICE_CODE, specialPriceCode);
    }//from w w  w .ja  v a 2s.  c  om
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.authenticate.LogoutRedirector.java

private static Set<String> getRestrictedPageUris(HttpServletRequest request) {
    HttpSession session = request.getSession();

    @SuppressWarnings("unchecked")
    Set<String> restrictedPageUris = (Set<String>) session.getAttribute(ATTRIBUTE_RESTRICTED_PAGE_URIS);

    if (restrictedPageUris == null) {
        restrictedPageUris = new HashSet<String>();
        session.setAttribute(ATTRIBUTE_RESTRICTED_PAGE_URIS, restrictedPageUris);
    }/*from w w  w.  j a  v a 2  s .co m*/

    return restrictedPageUris;
}