---
title: "How to retrieve session object in jsf view"  
description: "How to retrieve session object in jsf view"  
author: "Manoj Bhatt"  
published: 2014-11-01  
updated: 2014-11-01  
canonical: https://www.mindstick.com/forum/2484/how-to-retrieve-session-object-in-jsf-view  
category: "asp.net"  
tags: ["session", "session variable"]  
reading_time: 2 minutes  

---

# How to retrieve session object in jsf view

I have a RequestController(@ManagedBean and @ViewScoped) it is view scoped because we are using some ajax calls.

I have a [dataTable](https://www.mindstick.com/blog/195/datatable-in-ado-dot-net) with [result](https://www.mindstick.com/blog/12011/advantages-of-getting-result-oriented-seo-from-an-agency) and each result with a [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net)

```
<p:commandButton action="#{requestController.requestDetail()}" icon="ui-icon-search" title="Detalhes">     <f:setPropertyActionListener target="#{requestController.backing.selectedRequestVO}" value="#{order}" /></p:commandButton>
```

This [method](https://www.mindstick.com/forum/166/webservice-method) is receiving the [selected object](https://answers.mindstick.com/qa/109819/how-to-add-a-transition-to-a-selected-object-in-powerpoint) of my dataTable and is set on the session, it is working, the [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) is that I don't know how to get this [session object](https://www.mindstick.com/forum/2365/session-object-in-mvc) from my view.

```
public void requestDetail() throws IOException {
        FacesContext context = FacesContext.getCurrentInstance();
    context.getExternalContext().getSessionMap().put("requestDetail",backing.selectedRequestVO);context.getExternalContext().redirect(context.getExternalContext().getRequestContextPath() + "/views/request/detail.html");
    }
```

\

I need to [access](https://www.mindstick.com/articles/12994/how-foreigners-can-access-blocked-websites-in-china) it from my view because this object has the [request](https://www.mindstick.com/blog/255/post-get-and-request-function-in-php) details.\

## Replies

### Reply by Anonymous User

It's just available by the attribute name which you specified yourself.\

```
#{requestDetail}
```

\
Note that this is not the correct approach. You should have another [session](https://www.mindstick.com/articles/12042/session-in-c-sharp) scoped managed bean which you inject as @ManagedProperty in the view scoped managed bean and then set the request detail as its property.\
\

```
@ManagedBean
@ViewScoped
public class RequestController {

    @ManagedProperty("#{requestDetail}")
    private RequestDetail requestDetail;

    public String requestDetail() {
        requestDetail.setSelectedRequestVO(backing.getSelectedRequestVO());
        return "/views/request/detail.html?faces-redirect=true";
    }

    // ...
}
```

\
with\
\

```
@ManagedBean
@SessionScoped
public class RequestDetail {

    private RequestVO selectedRequestVO;

    // ...
}
```

\
which you then access as follows\


---

Original Source: https://www.mindstick.com/forum/2484/how-to-retrieve-session-object-in-jsf-view

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
