---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# GlideScriptedProcessor - Scoped

# GlideScriptedProcessor - Scoped {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

The GlideScriptedProcessor API provides a customizable URL endpoint that can execute arbitrary server-side JavaScript code and produce output such as TEXT, JSON, or HTML. ServiceNow processors are equivalent to Java servlets.

Use this API in processor scripts to access the processor (servlet) capabilities. There are no constructors for the ScopedGlideScriptedProcessor APIs. The methods are called using the global variable
<var class="keyword varname">g_processor</var>.

A useful global variable, <var class="keyword varname">g_target</var>, is available in processor scripts. It contains the table name extracted from the URL.

The URL to a processor has the format: https://\<instance name.servicenow.com\>/\<path endpoint\>.do?\<parameter endpoint\>=\<value\> where
the path endpoint and parameter endpoint are defined on the processor form.

## GlideScriptedProcessor - redirect(String url) {#ariaid-title2}

Redirects to the specified URL.
{#r_ScopedGlideScriptedProcessorRedirect_String__table_glg_5k5_qr__entry__3}

| Name | Type | Description |
|-|-|-|
| url | String | Destination URL |
[Table 1. Parameters]

{#r_ScopedGlideScriptedProcessorRedirect_String__table_glg_5k5_qr} {#r_ScopedGlideScriptedProcessorRedirect_String__table_hlg_5k5_qr__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 2. Returns]

{#r_ScopedGlideScriptedProcessorRedirect_String__table_hlg_5k5_qr}  

    //Do whatever processing you need and redirect to the homepage
    g_processor.redirect("/navpage.do")

## GlideScriptedProcessor - writeJSON(Object o) {#ariaid-title3}

Encodes an object as a JSON string and writes it to the current URL.
{#r_ScopedGlideScriptedProcessorWriteJSON_Object__table_b42_fn5_qr__entry__3}

| Name | Type | Description |
|-|-|-|
| o | Object | The object to encode to a JSON string. |
[Table 3. Parameters]

{#r_ScopedGlideScriptedProcessorWriteJSON_Object__table_b42_fn5_qr} {#r_ScopedGlideScriptedProcessorWriteJSON_Object__table_c42_fn5_qr__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 4. Returns]

{#r_ScopedGlideScriptedProcessorWriteJSON_Object__table_c42_fn5_qr}  

    var map = {"key1":"value1","key2":"value2"};
    g_processor.writeJSON(map);

## GlideScriptedProcessor - writeOutput(String s) {#ariaid-title4}

Writes the specified string to the current URL.
{#r_ScopedGlideScriptedProcessorWriteOutput_String__table_vm5_kl5_qr__entry__3}

| Name | Type | Description |
|-|-|-|
| s | String | The string to write. |
[Table 5. Parameters]

{#r_ScopedGlideScriptedProcessorWriteOutput_String__table_vm5_kl5_qr} {#r_ScopedGlideScriptedProcessorWriteOutput_String__table_wm5_kl5_qr__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 6. Returns]

{#r_ScopedGlideScriptedProcessorWriteOutput_String__table_wm5_kl5_qr}  

    var name = g_request.getParameter("name");
    g_processor.writeOutput("Hello " + name);

## GlideScriptedProcessor - writeOutput(String contentType, String s) {#ariaid-title5}

Writes the specified string to the current URL in the specified
character-encoding.
{#r_ScopedGlideScriptedProcessorWriteOutput_String_String__table_jdv_dm5_qr__entry__3}

| Name | Type | Description |
|-|-|-|
| contentType | String | Sets the content type of the response sent to the client, if the response has not been committed, and may include a character-encoding specification. |
| s | String | String to write. |
[Table 7. Parameters]

{#r_ScopedGlideScriptedProcessorWriteOutput_String_String__table_jdv_dm5_qr} {#r_ScopedGlideScriptedProcessorWriteOutput_String_String__table_kdv_dm5_qr__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 8. Returns]

{#r_ScopedGlideScriptedProcessorWriteOutput_String_String__table_kdv_dm5_qr}  

    var name = g_request.getParameter("name");
    g_processor.writeOutput("text/plain", "Hello " + name);


