BBjspWebRequest (Deprecated)

The BBJSP system is deprecated. For new development, use BBxServlet.

Description

In BBj 16.0 and higher, the BBjspWebRequest object provides methods for querying the state of an HTTP request.

The BBjspWebRequest provides a temporary store for attributes that are available during the processing of the current page and any CustomTag used in page processing.

Creation

BBJSP > BBjspPageContext > BBjspWebRequest

The BBjspWebRequest is created through the following BBjspPageContext method:

Return Value

Method

BBjspWebRequest

getRequest()

Methods of BBjspWebRequest

Return Value

Method

Object

getAttribute(string name)

BBjVector

getAttributeNames()

string

getAuthType()

string

getBody()

string

getCharacterEncoding()

int

getContentLength()

string

getContentType()

string

getContextPath()

BBjVector

getCookies()

BBjFileUpload

getFileUpload(string name)

BBjVector

getFileUploads()

string

getHeader(string name)

BBjVector

getHeaderNames()

BBjVector

getHeaders(string name)

string

getLocalAddr()

string

getLocalName()

int

getLocalPort()

Locale

getLocale()

BBjVector

getLocales()

string

getMethod()

string

getParameter(string name)

BBjVector

getParameterNames()

BBjVector

getParameterValues(string name)

string

getPathInfo()

string

getProtocol()

string

getQueryString()

string

getRemoteAddr()

string

getRemoteHost()

int

getRemotePort()

string

getRemoteUser()

string

getRequestURI()

string

getRequestURL()

string

getRequestedSessionId()

string

getScheme()

string

getServerName()

int

getServerPort()

string

getServletPath()

BBjspWebSession

getSession()

boolean

isRequestedSessionIdFromCookie()

boolean

isRequestedSessionIdFromURL()

boolean

isRequestedSessionIdValid()

boolean

isSecure()

void

removeAttribute(string name)

void

setAttribute(string name, Object value)

Example

This example demonstrates how this works in a BBJSP web-page

<%@ taglib uri='/WEB-CFG/tld/core.tld' prefix='c' %>
<html>
    <body>
        <h1>Hello from BBJSP</h1>
        Character Encoding:<%= #getRequest().getCharacterEncoding() %><br>
        Server Protocol:<%= #getRequest().getProtocol() %> <br>
        Method:<%= #getRequest().getMethod() %><br>
        Request Scheme: <%=#Request!.getScheme() %><br>
        Server Name:<%= #getRequest().getServerName() %><br>
        Server Port:<%= #getRequest().getServerPort() %><br>
        Servlet Path:<%= #getRequest().getServletPath() %><br>
        Request URL: <%=#Request!.getRequestURI() %><br>
        Request URL: <%=#Request!.getRequestURL() %><br>
        Path Info:<%= #getRequest().getPathInfo() %><br>
        Remote Address:<%= #getRequest().getRemoteAddr() %><br>
        Remote Host:<%= #getRequest().getRemoteHost() %><br>
        Remote Port:<%= #getRequest().getRemotePort() %><br>
        Remote User:<%= #getRequest().getRemoteUser() %><br>
        Requested Session ID:<%= #getRequest().getRequestedSessionId() %><br>
        Local Address:<%= #getRequest().getLocalAddr() %><br>
        Local Port:<%= #getRequest().getLocalPort() %><br>
        Session ID:<%= #Session!.getId() %><br>
        <c:if test='<%= #getRequest().isRequestedSessionIdFromCookie() %>' >
            SessionID came from cookie
        </c:if>
        <c:if test='<%= #getRequest().isRequestedSessionIdFromURL() %>' >
            SessionID came from cookie
        </c:if>
        <br>
        Requested Session ID is
        <c:if test='<%= #getRequest().isRequestedSessionIdValid() %>' >
            VALID
        </c:if>
        <c:ifnot test='<%= #getRequest().isRequestedSessionIdValid() %>' >
            INVALID
        </c:ifnot>
        <hr>
        <form method='post'>
            <input name='inputA' /><input name='inputB' /><input name='inputC' />
            <input type='submit'/>
        </form>
    </body>
</html>

This example demonstrates how this works in a BBJSP servlet

class public MyServlet

  field private BBjspWebRequest request!
  field private BBjspWebResponse response!
  field private BBjspWebSession session!
  
  method public void service(BBjspServletContext context!)
       
    #request! = context!.getRequest()
    #response! = context!.getResponse()

    #response!.setContentType("text/html")
    s! = #response!.getOutputStream()
    
    s!.write("<html><body><h1>Hello from BBJSP</h1>")
    s!.write(#request!.getMethod())
    s!.write(#request!.getBody())
    s!.write("</body></html>")
  methodend
classend

See Also

BBJSP

BBjspWebResponse

BBjVector

BBjFileUpload

BBjspRequestUtil