Imports a servlet bean or JavaBean component into a JSP.
<dsp:importbean bean="Nucleus-path
"[
var="attr-name
"[
scope="scope-spec
"]
]
dsp:importbean
can import a servlet bean or a JavaBean component into a JSP. After a component is imported, references to it can omit its full Nucleus path. You can also use dsp:importbean
to map the imported component to a scoped attribute that is EL-accessible. dsp:importbean
tags are typically placed at the top of the JSP, in order to facilitate references to them.
Attributes
bean
Set to the fully-qualified Nucleus path and name of the servlet bean to import.
var
Names an EL variable that enables access to other page tags. When you use var
, you can set its scope
attribute to page
, request
, session
, or application
. The default scope is page
.
If var
is omitted, the shorthand name for the component is used.
scope
By default, the named variable is set to page scope, which makes it accessible to any EL-enabled resources on the same page. The scope attribute lets you define a larger scope for variable, by setting it to request
, session
, or application
. For more information, see EL Variable Scopes.
Example
<dsp:importbean bean="/atg/dynamo/droplet/Switch"/> <dsp:importbean bean="/atg/dynamo/droplet/Redirect/> <dsp:importbean bean="/atg/dynamo/servlet/RequestLocale" var="requestlocale"/> <dsp:setvalue bean="${requestLocale.refresh}" value=" "/> <dsp:droplet name="Switch"> <dsp:param bean="${requestLocale.locale.language}" name="value"/> <dsp:oparam name="fr"> <dsp:droplet name="Redirect"> <dsp:param name="url" value="fr/index.jsp"/> </dsp:droplet> </dsp:oparam> <dsp:oparam name="de"> <dsp:droplet name="Redirect"> <dsp:param name="url" value="de/index.jsp"/> </dsp:droplet> </dsp:oparam> <dsp:oparam name="default"> <dsp:droplet name="Redirect"> <dsp:param name="url" value="en/index.jsp"/> </dsp:droplet> </dsp:oparam> </dsp:droplet>
In this example, Switch
, RequestLocale
, and Redirect
are imported to the current JSP. When these components are used elsewhere in the page, they use the component and property names only. The RequestLocale
component is imported to a var
attribute so the dsp:setvalue
and dsp:param
tags can access RequestLocale
with EL.