BBjspWebResponse::getCharacterEncoding (Deprecated)

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

Description

In BBj 16.0 and higher, this method returns the name of the character encoding (MIME charset) used for the body sent in this response. The character encoding may have been specified explicitly using the BBjspWebResponse::setCharacterEncoding(String) or BBjspWebResponse::setContentType(String) methods, or implicitly using the BBjspWebResponse::setLocale(Locale) method. Explicit specifications take precedence over implicit specifications. Calls made to these methods after the response has been committed have no effect on the character encoding. If no character encoding has been specified, ISO-8859-1 is returned.

Syntax

Return Value

Method

String

getCharacterEncoding()

Parameters

None.

Return Value

a string specifying the name of the character encoding, for example, UTF-8

Remarks

The example below shows getting the character encoding of a response within a BBJSP Servlet.

Example

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

<html>
    <body>
        <h1>Hello from BBJSP</h1>
        Character Encoding:<%= #Response!.getCharacterEncoding() %>
    </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("Character Encoding:"+ #response!.getCharacterEncoding())
    s!.write("</body></html>")
  methodend
classend

See Also

BBJSP

BBjspWebRequest

BBjspWebResponse