BBjspWebResponse::setLocale (Deprecated)

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

Description

In BBj 16.0 and higher, this method sets the locale of the response. It also sets the response's character encoding appropriately for the locale, if the character encoding has not been explicitly set using the BBjspWebResponse::setContentType(String) or BBjspWebResponse::setCharacterEncoding(String).

This method may be called repeatedly to change locale and character encoding. It does not set the response's character encoding if it is called after BBjspWebResponse::setContentType(String) has been called with a character set specification or after BBjspWebResponse::setCharacterEncoding(String) has been called.

Syntax

Return Value

Method

void

setLocale(Locale locale)

Parameters

Variable

Description

locale

the locale of the response

Return Value

None.

Remarks

The example below shows setting a Locale within a BBJSP Servlet.

Example

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

<%
    #getResponse().setLocale(new java.lang.Locale("fr", "CA"))
%>
<html>
    <body>
        <h1>Hello from BBJSP</h1>
        Set Locale:<%= #getResponse().getLocale() %>
    </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()
    
    response.setLocale(new java.lang.Locale("fr", "CA"))
    s!.write("<html><body><h1>Hello from BBJSP</h1>")
    s!.write("Locale:" + str(#response!.getLocale()))
    s!.write("</body></html>")
  methodend
classend

See Also

BBJSP

BBjspWebResponse::getLocale()