/** * Creates a Vaadin request for a http servlet request. This method can be * overridden if the Vaadin request should have special properties. * * @param request * the original http servlet request * @return a Vaadin request for the original request */ protected VaadinServletRequest createVaadinRequest( HttpServletRequest request) { return new VaadinServletRequest(request, getService()); }
/** * Gets a relative path you can use to refer to the context root. * * @param request * the request for which the location should be determined * @return A relative path to the context root. Never ends with a slash (/). * * @since 8.0.3 */ public static String getContextRootRelativePath(VaadinRequest request) { VaadinServletRequest servletRequest = (VaadinServletRequest) request; // Generate location from the request by finding how many "../" should // be added to the servlet path before we get to the context root String servletPath = servletRequest.getServletPath(); if (servletPath == null) { // Not allowed by the spec but servers are servers... servletPath = ""; } String pathInfo = servletRequest.getPathInfo(); if (pathInfo != null && !pathInfo.isEmpty()) { servletPath += pathInfo; } return getCancelingRelativePath(servletPath); }
@Override public WrappedSession getWrappedSession(boolean allowSessionCreation) { HttpSession session = getSession(allowSessionCreation); if (session != null) { return new WrappedHttpSession(session); } else { return null; } }
VaadinServletRequest vsRequest = (VaadinServletRequest)request; HttpServletRequest hsRequest = vsRequest.getHttpServletRequest(); String un = hsRequest.getParameter("username");
@Override public WrappedSession getWrappedSession() { return getWrappedSession(true); }
if (request.getRequestedSessionId() == null) {
@Override public String getParameter(String name) { if ("v-loc".equals(name)) { return location; } return super.getParameter(name); }
/** * Gets a relative path you can use to refer to the context root. * * @param request * the request for which the location should be determined * @return A relative path to the context root. Never ends with a slash (/). */ public static String getContextRootRelativePath(VaadinRequest request) { VaadinServletRequest servletRequest = (VaadinServletRequest) request; // Generate location from the request by finding how many "../" should // be added to the servlet path before we get to the context root // Should not take pathinfo into account because the base URI refers to // the servlet path String servletPath = servletRequest.getServletPath(); assert servletPath != null; if (!servletPath.endsWith("/")) { servletPath += "/"; } return ServletHelper.getCancelingRelativePath(servletPath); }
StringBuilder jsCall = new StringBuilder(); jsCall.append("var request = new XMLHttpRequest();"); jsCall.append("request.open(\"GET\", \""); jsCall.append(AdminUI.getS42Url()); //set credentials to user: _ and pw: _ jsCall.append("\", true, \"_\", \"_\");"); jsCall.append("request.send();"); //execute JS call JavaScript.getCurrent().execute(jsCall.toString()); //logout user and destroy session VaadinRequest vaadinRequest = VaadinService.getCurrentRequest(); VaadinServletRequest vaadinServletRequest = (VaadinServletRequest) vaadinRequest; HttpServletRequest hsRequest = vaadinServletRequest.getHttpServletRequest(); try { hsRequest.logout(); } catch (ServletException e) { LOG.error("", e); }
@Override public WrappedSession getWrappedSession() { return getWrappedSession(true); }
if (request.getRequestedSessionId() == null) {
@Override public String getParameter(String name) { if ("v-loc".equals(name)) { return location; } return super.getParameter(name); }
VaadinServletRequest vaadinRequest = new VaadinServletRequest( resource.getRequest(), service); VaadinSession session = null;
private void addHeader() { if (m_headerProvider != null) { try { setHeaderHtml(getHeader(((VaadinServletRequest) m_request).getHttpServletRequest())); } catch (final Exception e) { LOG.error("failed to get header HTML for request " + m_request.getPathInfo(), e); } } if (m_headerHtml != null) { InputStream is = null; try { is = new ByteArrayInputStream(m_headerHtml.getBytes()); final CustomLayout headerLayout = new CustomLayout(is); headerLayout.setWidth("100%"); headerLayout.addStyleName("onmsheader"); m_rootLayout.addComponent(headerLayout); } catch (final IOException e) { closeQuietly(is); LOG.debug("failed to get header layout data", e); } } }
@Override public String getStaticFileLocation(VaadinRequest request) { VaadinServletRequest servletRequest = (VaadinServletRequest) request; String staticFileLocation; // if property is defined in configurations, use that staticFileLocation = getDeploymentConfiguration().getResourcesPath(); if (staticFileLocation != null) { return staticFileLocation; } // the last (but most common) option is to generate default location // from request by finding how many "../" should be added to the // requested path before we get to the context root String requestedPath = servletRequest.getServletPath(); String pathInfo = servletRequest.getPathInfo(); if (pathInfo != null) { requestedPath += pathInfo; } return getCancelingRelativePath(requestedPath); }
@Override public WrappedSession getWrappedSession(boolean allowSessionCreation) { HttpSession session = getSession(allowSessionCreation); if (session != null) { return new WrappedHttpSession(session); } else { return null; } }
/** * Create a Vaadin request for a http servlet request. This method can be * overridden if the Vaadin request should have special properties. * * @param request * the original http servlet request * @return a Vaadin request for the original request */ protected VaadinServletRequest createVaadinRequest( HttpServletRequest request) { return new VaadinServletRequest(request, getService()); }
private void addHeader(VaadinRequest request) { if (m_headerProvider != null) { try { setHeaderHtml(m_headerProvider.getHeaderHtml(((VaadinServletRequest) request).getHttpServletRequest())); } catch (final Exception e) { LOG.error("failed to get header HTML for request " + request.getPathInfo(), e); } } if (m_headerHtml != null) { InputStream is = null; try { is = new ByteArrayInputStream(m_headerHtml.getBytes()); final CustomLayout headerLayout = new CustomLayout(is); headerLayout.setWidth("100%"); headerLayout.addStyleName("onmsheader"); m_rootLayout.addComponent(headerLayout); } catch (final IOException e) { closeQuietly(is); LOG.debug("failed to get header layout data", e); } } }
final PushEventCallback callback, boolean websocket) { AtmosphereRequest req = resource.getRequest(); VaadinServletRequest vaadinRequest = new VaadinServletRequest(req, service); VaadinSession session = null;
private void addHeader(VaadinRequest request) { if (m_headerProvider != null) { try { setHeaderHtml(m_headerProvider.getHeaderHtml(((VaadinServletRequest) request).getHttpServletRequest())); } catch (final Exception e) { LOG.error("failed to get header HTML for request " + request.getPathInfo(), e); } } if (m_headerHtml != null) { InputStream is = null; try { is = new ByteArrayInputStream(m_headerHtml.getBytes()); final CustomLayout headerLayout = new CustomLayout(is); headerLayout.setWidth("100%"); headerLayout.addStyleName("onmsheader"); m_rootLayout.addComponent(headerLayout); } catch (final IOException e) { closeQuietly(is); LOG.debug("failed to get header layout data", e); } } }