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
ImportedComponent:bean(Required)
The bean
attribute accepts the fully-qualified Nucleus path and name for the servlet bean you want to import.
ServletBeanasanAttribute:var
The var
attribute names an EL variable that makes the servlet bean instance accessible to other tags on the page. When var
is omitted, the shorthand name for the component is used.
VariableScope:scope
The scope
attribute determines where the servlet bean variable identified by the var
attribute is stored and what resources can access it. Options include: page
, request
, session
, or application
. Omitting this attribute causes the default, page
, to be used.
Example
<dsp:importbean bean="/atg/dynamo/droplet/Switch"/> <dsp:importbean bean="/atg/dynamo/servlet/RequestLocale" var="requestlocale"/> <dsp:importbean bean="/atg/dynamo/droplet/Redirect/> <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.
This code sample uses tags from the DSP and JSTL Core tag library.