Trace: • Using HttpContext
The com.sibvisions.rad.server.http.HttpContext is useful for application server deployments. It allows accessing the original request and response from the http connection. If you need access to the HttpRequest, HttpResponse, PortletReqeust or PortletResponse, simply use the HttpContext.
The HttpContext is in use for JVx' Server, REST interface, Mobile server, Vaadin UI and other projects using JVx.
Simply use HttpContext to get the request URL:
HttpContext ctxt = HttpContext.getCurrentInstance(); if (ctxt != null) { Object oRequest = ctxt.getRequest(); if (oRequest instanceof HttpServletRequest) { String sURI = ((HttpServletRequest)oRequest).getRequestURL().toString(); } else { //e.g. PortletRequest } }
The HttpContext is available in application server environments and will be created before the ServerContext.