# Request attribute from Java class/method

**URL:** <https://community.dynatrace.com/t/request-attribute-from-java-class-method/20362>\
**Category:** Open Q&A\
**Tags:** request-attributes\
**Created:** [September 23, 2020, 11:59am UTC](https://community.dynatrace.com/t/request-attribute-from-java-class-method/20362 "2020-09-23T11:59:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![henk\_stobbe](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/henk_stobbe/32/30434_2.png) [@henk\_stobbe](https://community.dynatrace.com/u/henk_stobbe)\
**Post date:** [September 23, 2020, 11:59am UTC](https://community.dynatrace.com/t/request-attribute-from-java-class-method/20362/1 "2020-09-23T11:59:18Z")

</div>

Hello,

Just to make sure I understand:

To use a getter in retrieving attribute data, is has to exists in the the class to start with?

and

Using This means you get the “start” value of the getter, and using return option will give you the “end” value?

KR Henk

---

<div class="post-metadata">

**Author:** ![JamesKitson](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/jameskitson/32/22460_2.png) [@JamesKitson](https://community.dynatrace.com/u/JamesKitson)\
**Post date:** [September 24, 2020, 6:01pm UTC](https://community.dynatrace.com/t/request-attribute-from-java-class-method/20362/2 "2020-09-24T18:01:40Z")

</div>

Yes, it is true that the method (accessor) you enter there does have to exist. Dynatrace is actually executing that method has part of the process of getting the value - so make sure it truly does only return a value and doesn’t actually alter the state of the application.

“This” can be used if you want to access some property or variable _of that method_ the request attribute is configured on. Return value works on the object that is returned by the method. Some details here:

> **[Capture request attributes based on method arguments](https://docs.dynatrace.com/docs/observe/application-observability/services/request-attributes/capture-request-attributes-based-on-method-arguments)**
>
> Learn how to create request attributes based on Java, .NET, or PHP method arguments and how to use them on the service’s overview page. Also find out how you can aggregate the captured values of request attributes as well as how you can access...

---

<div class="post-metadata">

**Author:** ![dave\_mauney](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dave_mauney/32/27784_2.png) [@dave\_mauney](https://community.dynatrace.com/u/dave_mauney)\
**Post date:** [September 24, 2020, 7:08pm UTC](https://community.dynatrace.com/t/request-attribute-from-java-class-method/20362/3 "2020-09-24T19:08:23Z")

</div>

We can capture arguments to a method (input values) or the return value (an output value). If the values are strings, you are done at that point. If they are objects, you can use deep object access to call another x methods to get to the string data.

For example, if you get a UserContext object, you might call getUser() to get the User object and then getUserID() to get the user id as a string.

This would be something like “.getUser().getUserID()” to get that information.
