Page 1 of 1

--Using HttpContext

PostPosted: Tue Dec 09, 2014 3:53 pm
by Development@SIB


This article is outdated - please use our new system at

https://doc.sibvisions.com




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:
Syntax: [ Download ] [ Hide ]
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.