Example usage for javax.servlet.http HttpServletRequest getRequestedSessionId

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

Introduction

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

Prototype

public String getRequestedSessionId();

Source Link

Document

Returns the session ID specified by the client.

Usage

From source file:org.kuali.kra.web.filter.SessionExpiredFilter.java

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    HttpServletRequest hrequest = (HttpServletRequest) request;

    if (hrequest.getRequestedSessionId() != null && hrequest.isRequestedSessionIdValid() == false) {
        hrequest.getSession().setAttribute(KeyConstants.SESSION_EXPIRED_IND, new Boolean(true));
    }//from  www  .j  a v  a 2  s .  co  m

    chain.doFilter(request, response);
}

From source file:org.mskcc.cbio.portal.servlet.BoxPlotServlet.java

/** 
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code> 
 * methods./*from   w  ww.  java2 s .  co m*/
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    try {
        // get data
        String format = servletXssUtil.getCleanInput(request, FORMAT);
        String strData = servletXssUtil.getCleanInput(request, DATA);
        String xlabel = servletXssUtil.getCleanInput(request, XLABEL);
        String ylabel = servletXssUtil.getCleanInput(request, YLABEL);
        String width = servletXssUtil.getCleanInput(request, PLOT_WIDTH);
        String height = servletXssUtil.getCleanInput(request, PLOT_HEIGHT);

        xlabel = WordUtils.wrap(StringEscapeUtils.unescapeHtml(xlabel), 60, "\\n", false);
        ylabel = StringEscapeUtils.unescapeHtml(ylabel);

        if (format == null || !format.equals("pdf")) {
            format = "png"; // default is png
        }

        List<Double> values = new ArrayList<Double>();
        List<String> tags = new ArrayList<String>();

        for (String groupData : strData.split(";")) {
            if (groupData.isEmpty()) {
                continue;
            }

            int ix = groupData.indexOf(':');
            if (ix == -1 || ix == groupData.length() - 1) {
                continue;
            }

            String group = groupData.substring(0, ix);
            for (String value : groupData.substring(ix + 1).split(",")) {
                values.add(Double.parseDouble(value));
                tags.add(group);
            }
        }

        StringBuilder plot = new StringBuilder();

        String tmpfile = "tmp" + request.getRequestedSessionId()
                + String.valueOf(System.currentTimeMillis() + "." + format);

        plot.append("library(Cairo);\n");
        if (format.equals("pdf")) {
            plot.append("pdf(width=6, height=6, file='");
            plot.append(tmpfile);
            plot.append("');\n");
        } else {
            plot.append("Cairo(width=");
            plot.append(width);
            plot.append(", height=");
            plot.append(height);
            plot.append(", file='");
            plot.append(tmpfile);
            plot.append("', type='");
            plot.append(format);
            plot.append("', units=\"px\")\n");
        }

        plot.append("data=c(");
        plot.append(StringUtils.join(values, ","));
        plot.append(");\n");

        plot.append("group=c('");
        plot.append(StringUtils.join(tags, "','"));
        plot.append("');\n");

        plot.append("boxplot(data~group,outline=F,ylim=(c(min(data),max(data))),xlab='");
        plot.append(xlabel);
        plot.append("',ylab='");
        plot.append(ylabel);
        plot.append("');\n");

        plot.append("stripchart(data~group, add=T, pch=16, vertical=T, method='jitter', jitter=0.1);\n");
        plot.append("dev.off();\n");

        logger.debug("Call to R Follows:");
        logger.debug(plot.toString());

        //response.getWriter().print(plot);

        RConnection c = new RConnection();

        // open device
        try {
            c.parseAndEval(plot.toString());
        } catch (org.rosuda.REngine.REngineException e) {
            if (!new File(tmpfile).exists()) {
                throw e;
            }
        }

        // There is no I/O API in REngine because it's actually more efficient to use R for this
        // we limit the file size to 1MB which should be sufficient and we delete the file as well
        REXP xp = c.parseAndEval("r=readBin('" + tmpfile + "','raw',1024*1024); unlink('" + tmpfile + "'); r;");

        // now this is pretty boring AWT stuff - create an image from the data and display it ...
        byte[] imageBytes = xp.asBytes();
        response.setContentLength(imageBytes.length);
        response.getOutputStream().write(imageBytes);
        c.close();

        if (format.equals("pdf")) {
            response.setContentType("application/pdf");
        } else {
            response.setContentType("image/png");
        }
    } catch (Exception e) {
        //  In the event of an exception, redirect to the Plot NA Image.
        logger.error(e);
        response.sendRedirect("images/plots_na.png");
    }
}

From source file:org.n52.v3d.terrainserver.demservice.DEMServlet.java

private void logGetCapabilitiesInfo(String pTmpName, HttpServletRequest pRequest) {
    try {/*from   ww w .  j  av  a 2s  .c  o m*/
        PrintWriter lDat = new PrintWriter(new FileWriter(mWorkingDirectory + "/" + pTmpName + ".log"));

        lDat.println("REMOTE HOST: " + pRequest.getRemoteHost());
        lDat.println("REMOTE ADDRESS: " + pRequest.getRemoteAddr());
        //lDat.println("REMOTE USER: " + pRequest.getRemoteUser());
        lDat.println("QUERY STRING: " + pRequest.getQueryString());
        lDat.println("SESSION-ID: " + pRequest.getRequestedSessionId());

        lDat.close();
    } catch (IOException e) {
        throw new T3dException(e.getMessage());
    }
}

From source file:org.n52.v3d.terrainserver.demservice.DEMServlet.java

private void logGetDEMInfo(String pTmpName, VgEnvelope pBBox, double pCellSize, T3dTimeList pTimeProt,
        HttpServletRequest pRequest, String pFormat) {
    try {// w ww . j ava2  s. c  o  m
        PrintWriter lDat = new PrintWriter(new FileWriter(mWorkingDirectory + "/" + pTmpName + ".log"));

        lDat.println("REMOTE HOST: " + pRequest.getRemoteHost());
        lDat.println("REMOTE ADDRESS: " + pRequest.getRemoteAddr());
        //lDat.println("REMOTE USER: " + pRequest.getRemoteUser());
        lDat.println("QUERY STRING: " + pRequest.getQueryString());
        lDat.println("SESSION-ID: " + pRequest.getRequestedSessionId());
        lDat.println("BBOX: " + pBBox);
        lDat.println("CELLSIZE: " + pCellSize);
        lDat.println("OUTPUT FORMAT: " + pFormat);
        lDat.println("PROCESSING_TIMES [msec]: ");
        String[] lTimeProtStr = pTimeProt.protocol();
        for (int i = 0; i < lTimeProtStr.length; i++)
            lDat.println(lTimeProtStr[i]);

        lDat.close();
    } catch (IOException e) {
        throw new T3dException(e.getMessage());
    }
}

From source file:org.n52.v3d.terrainserver.demservice.DEMServlet.java

private void logErrorInfo(String pTmpName, HttpServletRequest pRequest, Throwable pExc) {
    try {//from   ww  w  .ja  va  2s . com
        PrintWriter lDat = new PrintWriter(new FileWriter(mWorkingDirectory + "/" + pTmpName + ".log"));

        lDat.println("REMOTE HOST: " + pRequest.getRemoteHost());
        lDat.println("REMOTE ADDRESS: " + pRequest.getRemoteAddr());
        //lDat.println("REMOTE USER: " + pRequest.getRemoteUser());
        lDat.println("QUERY STRING: " + pRequest.getQueryString());
        lDat.println("SESSION-ID: " + pRequest.getRequestedSessionId());
        lDat.println("ERROR: " + pExc.getMessage());
        lDat.println("STACK TRACE: ");
        pExc.printStackTrace(lDat);

        lDat.close();
    } catch (IOException e) {
        throw new T3dException(e.getMessage());
    }
}

From source file:org.n52.v3d.terrainserver.povraywts.WebTerrainServlet.java

private void logGetViewInfo(String pTmpName, VgElevationGrid pTerrain, T3dTimeList pTimeProt,
        HttpServletRequest pRequest, String pOutputInfo) {
    try {//  w  w  w  . jav a 2s . co m
        PrintWriter lDat = new PrintWriter(new FileWriter(mWorkingDirectory + "/" + pTmpName + ".log"));

        // Berarbeitungszeit und weitere Infos protokollieren:
        lDat.println("REMOTE HOST: " + pRequest.getRemoteHost());
        lDat.println("REMOTE ADDRESS: " + pRequest.getRemoteAddr());
        //lDat.println("REMOTE USER: " + pRequest.getRemoteUser());
        lDat.println("QUERY STRING: " + pRequest.getQueryString());
        lDat.println("SESSION-ID: " + pRequest.getRequestedSessionId());
        lDat.println("BBOX: " + pTerrain.getGeometry().envelope());
        lDat.println("BBOX-SIZE: " + pTerrain.getGeometry().envelope().areaXY());
        lDat.println("CELLSIZE: " + ((GmSimple2dGridGeometry) pTerrain.getGeometry()).getDeltaX()); // quidist.
        lDat.println("OUTPUT FORMAT: " + pOutputInfo);
        lDat.println("PROCESSING_TIMES [msec]: ");
        String[] lTimeProtStr = pTimeProt.protocol();
        for (int i = 0; i < lTimeProtStr.length; i++)
            lDat.println(lTimeProtStr[i]);

        lDat.close();
    } catch (IOException e) {
        throw new T3dException(e.getMessage());
    }
}

From source file:org.n52.v3d.terrainserver.povraywts.WebTerrainServlet.java

private void logErrorInfo(String pTmpName, T3dTimeList pTimeProt, HttpServletRequest pRequest, Throwable pExc) {
    try {/*from w w w  . j  a  va 2 s.  c  o m*/
        PrintWriter lDat = new PrintWriter(new FileWriter(mWorkingDirectory + "/" + pTmpName + ".log"));

        lDat.println("REMOTE HOST: " + pRequest.getRemoteHost());
        lDat.println("REMOTE ADDRESS: " + pRequest.getRemoteAddr());
        //lDat.println("REMOTE USER: " + pRequest.getRemoteUser());
        lDat.println("QUERY STRING: " + pRequest.getQueryString());
        lDat.println("SESSION-ID: " + pRequest.getRequestedSessionId());
        lDat.println("PROCESSING_TIMES [msec]: ");
        String[] lTimeProtStr = pTimeProt.protocol();
        for (int i = 0; i < lTimeProtStr.length; i++)
            lDat.println(lTimeProtStr[i]);
        lDat.println("ERROR: " + pExc.getMessage());
        lDat.println("STACK TRACE: ");
        pExc.printStackTrace(lDat);

        lDat.close();
    } catch (IOException e) {
        throw new T3dException(e.getMessage());
    }
}

From source file:org.n52.v3d.terrainserver.profileservice.ProfileServlet.java

private void logGetGraphInfo(String pTmpName, VgElevationGrid pTerrain, VgLineString pDefLine,
        T3dTimeList pTimeProt, HttpServletRequest pRequest, String pOutputInfo) {
    try {/* ww  w . j a  v a 2 s.co  m*/
        PrintWriter lDat = new PrintWriter(new FileWriter(mWorkingDirectory + "/" + pTmpName + ".log"));

        // Berarbeitungszeit und weitere Infos protokollieren:
        lDat.println("REMOTE HOST: " + pRequest.getRemoteHost());
        lDat.println("REMOTE ADDRESS: " + pRequest.getRemoteAddr());
        //lDat.println("REMOTE USER: " + pRequest.getRemoteUser());
        lDat.println("QUERY STRING: " + pRequest.getQueryString());
        lDat.println("SESSION-ID: " + pRequest.getRequestedSessionId());
        lDat.println("DEFLINE: " + pDefLine);
        lDat.println("BBOX: " + pTerrain.getGeometry().envelope());
        lDat.println("BBOX-SIZE: " + pTerrain.getGeometry().envelope().areaXY());
        lDat.println("CELLSIZE: " + ((GmSimple2dGridGeometry) pTerrain.getGeometry()).getDeltaX()); // quidist.
        lDat.println("OUTPUT FORMAT: " + pOutputInfo);
        lDat.println("PROCESSING_TIMES [msec]: ");
        String[] lTimeProtStr = pTimeProt.protocol();
        for (int i = 0; i < lTimeProtStr.length; i++)
            lDat.println(lTimeProtStr[i]);

        lDat.close();
    } catch (IOException e) {
        throw new T3dException(e.getMessage());
    }
}

From source file:org.n52.v3d.terrainserver.profileservice.ProfileServlet.java

private void logGetElevationInfo(String pTmpName, VgElevationGrid pTerrain, VgPoint pPoint,
        T3dTimeList pTimeProt, HttpServletRequest pRequest, String pOutputInfo) {
    try {//from   www.j  av  a2  s.  c  om
        PrintWriter lDat = new PrintWriter(new FileWriter(mWorkingDirectory + "/" + pTmpName + ".log"));

        // Berarbeitungszeit und weitere Infos protokollieren:
        lDat.println("REMOTE HOST: " + pRequest.getRemoteHost());
        lDat.println("REMOTE ADDRESS: " + pRequest.getRemoteAddr());
        //lDat.println("REMOTE USER: " + pRequest.getRemoteUser());
        lDat.println("QUERY STRING: " + pRequest.getQueryString());
        lDat.println("SESSION-ID: " + pRequest.getRequestedSessionId());
        lDat.println("POINT: " + pPoint);
        lDat.println("BBOX: " + pTerrain.getGeometry().envelope());
        lDat.println("BBOX-SIZE: " + pTerrain.getGeometry().envelope().areaXY());
        lDat.println("CELLSIZE: " + ((GmSimple2dGridGeometry) pTerrain.getGeometry()).getDeltaX()); // quidist.
        lDat.println("OUTPUT FORMAT: " + pOutputInfo);
        lDat.println("PROCESSING_TIMES [msec]: ");
        String[] lTimeProtStr = pTimeProt.protocol();
        for (int i = 0; i < lTimeProtStr.length; i++)
            lDat.println(lTimeProtStr[i]);

        lDat.close();
    } catch (IOException e) {
        throw new T3dException(e.getMessage());
    }
}

From source file:org.nuxeo.ecm.platform.ui.web.auth.NuxeoAuthenticationFilter.java

/**
 * Save requested URL before redirecting to login form.
 * <p>//  w  w w  .ja v  a2  s  .  co  m
 * Returns true if target url is a valid startup page.
 */
public boolean saveRequestedURLBeforeRedirect(HttpServletRequest httpRequest,
        HttpServletResponse httpResponse) {

    final boolean hasRequestedSessionId = !StringUtils.isBlank(httpRequest.getRequestedSessionId());

    HttpSession session = httpRequest.getSession(false);
    final boolean isTimeout = session == null && hasRequestedSessionId;

    if (!httpResponse.isCommitted()) {
        session = httpRequest.getSession(true);
    }

    if (session == null) {
        return false;
    }

    String requestPage;
    boolean requestPageInParams = false;
    if (httpRequest.getParameter(REQUESTED_URL) != null) {
        requestPageInParams = true;
        requestPage = httpRequest.getParameter(REQUESTED_URL);
    } else {
        requestPage = getRequestedUrl(httpRequest);
    }

    if (requestPage == null) {
        return false;
    }

    // add a flag to tell that the Session looks like having timed out
    if (isTimeout && !requestPage.equals(LoginScreenHelper.getStartupPagePath())) {
        session.setAttribute(SESSION_TIMEOUT, Boolean.TRUE);
    } else {
        session.removeAttribute(SESSION_TIMEOUT);
    }

    // avoid redirect if not useful
    if (requestPage.startsWith(LoginScreenHelper.getStartupPagePath())) {
        return true;
    }

    // avoid saving to session is start page is not valid or if it's
    // already in the request params
    if (isStartPageValid(requestPage)) {
        if (!requestPageInParams) {
            session.setAttribute(START_PAGE_SAVE_KEY, requestPage);
        }
        return true;
    }

    return false;
}