/** * 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()); }
@Override public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { VaadinServletRequest httpRequest = (VaadinServletRequest) request; boolean isFavicon = httpRequest.getContextPath().isEmpty() && httpRequest.getServletPath().isEmpty() && "/favicon.ico".equals(httpRequest.getPathInfo()); if (isFavicon) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); } return isFavicon; }
public static HttpServletRequest getCurrentServletRequest() { return VaadinServletRequest.getCurrent(); }
@Override public WrappedSession getWrappedSession() { return getWrappedSession(true); }
@Override public WrappedSession getWrappedSession(boolean allowSessionCreation) { HttpSession session = getSession(allowSessionCreation); if (session != null) { return new WrappedHttpSession(session); } else { return null; } }
/** * 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); }
try { ServletContext context = ((VaadinServletRequest) request) .getServletContext(); response.setContentType(streamResource.getContentTypeResolver() .apply(streamResource, context));
if (request.getRequestedSessionId() == null) {
return; VaadinServletRequest vaadinRequest = new VaadinServletRequest( resource.getRequest(), service); VaadinSession session;
final PushEventCallback callback, boolean websocket) { AtmosphereRequest req = resource.getRequest(); VaadinServletRequest vaadinRequest = new VaadinServletRequest(req, service); VaadinSession session = null;