Java Platform, Enterprise Edition (Java EE) 8 The Java EE Tutorial

## Relocatable Resources

You can place a resource tag in one part of a page and specify that it be rendered in another part of the page. To do this, you use the `target` attribute of a tag that specifies a resource. Acceptable values for this attribute are as follows.

- `"head"` renders the resource in the `head` element.

- `"body"` renders the resource in the `body` element.

- `"form"` renders the resource in the `form` element.

For example, the following `h:outputScript` tag is placed within an `h:form` element, but it renders the JavaScript in the `head` element:

    <h:form>
        <h:outputScript name="myscript.js" library="mylibrary" target="head"/>
    </h:form>

The `h:outputStylesheet` tag also supports resource relocation, in a similar way.

Relocatable resources are essential for composite components that use stylesheets and can also be useful for composite components that use JavaScript. See The compositecomponentexample Example Application for an example.

Copyright © 2017, Oracle and/or its affiliates. All rights reserved.