Download PDF
Download page Assisted Injection.
Assisted Injection
This page describes how to instrument a browser application through assisted injection of the JavaScript Agent. Assisted injection is when your server-side application injects the JavaScript Agent into your browser application. You can configure your business applications to inject the JavaScript Agent into your browser applications.
Types of Assisted Injection
You can perform assisted injection with rules or through attributes. This table summarizes the platforms supported for each type of assisted injection and the process for performing the assisted injection.
Type of Assisted Injection | Supported Platforms | Description |
---|---|---|
Injection Rules | Java | Type of assisted injection uses rules to configure which Java classes should be intercepted. You create the injection rules in the User Experience App Integration Panel of the Controller UI for the business application that will inject the JavaScript Agent. |
Attribute Injection | Java, ASP.NET | Type of assisted injection relies on templates that tell the app agent where to inject information. You enable attribute injection in the User Experience App Integration Panel of the Controller UI for the business application that will inject the JavaScript Agent. Additionally, you add code snippets in the page templates that determine where the JavaScript Agent is injected. |
Injection Rules (Java Only)
To have your server-side application use assisted injection of the JavaScript Agent using injection rules, you define rules to configure:
- The Java classes and methods that should be intercepted
- The Java writer object and method to use to add the agent to the response object
Assisted injection using rules is available for Java frameworks only.
Access the User Experience App Integration Panel
- From the Applications page, open the business application that you want to automatically inject the JavaScript Agent into your browser application.
- From the left navigation bar, select Configuration.
- Click User Experience App Integration.
Create JavaScript Injection Rules
- In the JavaScript Agent Injection tab, select a browser application from the Inject the JavaScript Agent configured for this Browser App dropdown.
- From the Configure JavaScript Injection tab, expand Create Injection Rules.
- Click the + icon to open the Create Manual Injection Rule dialog.
- From the Where to Inject JavaScript tab:
- In the Name field, enter a name for the rule.
- Check Enable.
- In the Class and Method to intercept section, define match conditions for the class and method that write to the output stream in your application. This is the class that server-side agent intercepts for injection.
- If the write method is overloaded:
Check the Is this Method Overloaded? checkbox.
- Click Add Parameter.
- Add the parameters that define the method.
- In the Pointer to the writer section:
- Select how to obtain a reference to the writer object using either the selected method with a configured number of parameters, return value, or invoked object.
- Specify a getter chain.
- In the Injection options section, specify:
- the output stream write method the server-side agent should use to inject the JavaScript Agent
- when the injection should occur: when the method begins or when the method ends
- which part of the script should be injected: the header or the footer
- optional prefix to output before writing the header or footer, such as
<DOCTYPE. . . >
- Click Create Injection Rule.
Attribute Injection
To have your server-side application use assisted injection of the JavaScript Agent using attribute injection, you:
- Enable attribute injection
- Copy code snippets into your page template
Only Servlet containers supported assisted injection.
Access the User Experience App Integration Panel
- From the Applications page, open the business application that you want to automatically inject the JavaScript Agent into your browser application.
- From the left navigation bar, select Configuration.
- Click User Experience App Integration.
Access the JavaScript Injection Configuration Panel
- From the User Experience App Integration page, click the JavaScript Agent Injection tab.
- In the JavaScript Agent Injection tab, select a browser application from the Inject the JavaScript Agent configured for this Browser App dropdown.
Copy Code Snippets into Your Page Template
These examples show code snippets that you can copy directly into your page templates or into other pages. These code snippets direct the app agent where to inject information. The header value must be injected at the very top of the <head>
section and the footer value must be added at the very end of the code creating the page.
If you have already injected the header portion of the agent using manual injection, you can use these code snippets to automatically inject the footer data portion only. In this case, add only the JS_FOOTER
values shown in the sections below.
JSF
<h:outputText rendered="#{AppDynamics_JS_HEADER != null}" value='#{request.getAttribute("AppDynamics_JS_HEADER")}' escape="false"/>
<h:outputText rendered="#{AppDynamics_JS_FOOTER != null}" value='#{request.getAttribute("AppDynamics_JS_FOOTER")}' escape="false"/>
JSP
<% if (request.getAttribute("AppDynamics_JS_HEADER") != null) { %> <%=request.getAttribute("AppDynamics_JS_HEADER")%> <% } %>
<% if (request.getAttribute("AppDynamics_JS_FOOTER") != null) { %> <%=request.getAttribute("AppDynamics_JS_FOOTER")%> <% } %>
Servlet
if (request.getAttribute("AppDynamics_JS_HEADER") != null)
{
out.write(request.getAttribute("AppDynamics_JS_HEADER".toString());
}
if (request.getAttribute("AppDynamics_JS_FOOTER") != null)
{
out.write(request.getAttribute("AppDynamics_JS_FOOTER").toString());
}
Groovy
<g:if test="${AppDynamics_JS_HEADER}">
${AppDynamics_JS_HEADER}
</g:if>
<g:if test="${AppDynamics_JS_FOOTER}">
${AppDynamics_JS_FOOTER}
</g:if>
Velocity Template
#if ($AppDynamics_JS_HEADER)
$AppDynamics_JS_HEADER
#end
#if ($AppDynamics_JS_FOOTER)
$AppDynamics_JS_FOOTER
#end
ASP.NET C#
<% if (Context.Items.Contains("AppDynamics_JS_HEADER"))
Response.Write(Context.Items["AppDynamics_JS_HEADER"]); %>
<% if (Context.Items.Contains("AppDynamics_JS_FOOTER"))
Response.Write(Context.Items["AppDynamics_JS_FOOTER"]); %>
MVC Razor
@if(HttpContext.Current.Items.Contains("AppDynamics_JS_HEADER"))
{ @Html.Raw((string)HttpContext.Current.Items["AppDynamics_JS_HEADER"]) }
@if(HttpContext.Current.Items.Contains("AppDynamics_JS_FOOTER") )
{ @Html.Raw(HttpContext.Current.Items["AppDynamics_JS_FOOTER"].ToString()) }