Call java method on JSP (change company)

Hello, I am trying to have a dropdown which permit, when it’s clicked, to change the active company.
I did the dropdown and succeeded in getting UserID, UserVersion and the chosen Company ID.
All i have to do know is to use the java method : userActive.setActiveCompany(CompanyChosen)

But without succeess. (I tried with API, with direct java, with beans, with MouseListenner (in java)…).
But I am now without options.
Could you please me explain how you would do that ?

Here is how I did my modif in index.jsp:

User userActive = AuthUtils.getUser();
Set<Company> c = userActive.getCompanySet();%>
    <li class="divider-vertical"></li>
    <li class="dropdown">
        <a href="javascript:" class="dropdown-toggle nav-link-user" data-toggle="dropdown">
            <i class="fa fa-building"></i>
            <b class="caret"></b>
        <ul class="dropdown-menu">
                <a href="#/preferences">
                    <span class="nav-link-user-name"><%=userActive.getActiveCompany().getName()%></span>
                    <span class="nav-link-user-sub">active</span>
            <% if (tenantMap != null && tenantMap.size() > 1) { %>
            <li class="divider"></li>
            <li class="dropdown-submenu">
                <a tabIndex="-1" href="" x-translate>More...</a>
                <ul class="dropdown-menu">
                    <% for (String key : tenantMap.keySet()) { %>
                    <% if (!key.equals(tenantId)) { %>
                    <li><a href="callback?tenant=<%= key %>"><%= tenantMap.get(key) %>
                    <% } %>
                    <% } %>
            <% } %>
            <li class="divider"></li>
                                for (Company CompanyList : c) {
                                    if (!userActive.getActiveCompany().getName().equals(CompanyList.getName())) {%>
            <li><a class="myCompany" data-companyid="<%=CompanyList.getId()%>" data-userid="<%=userActive.getId()%>"
            <% } %>
            <% } %>


i called angular controller on company name

i have extended it further and it is purely angular directive now, and it reload once the active company get changed

Could you be more specific with code example?
Thank you for your help Siddique

sharing gist link so you can see in detail

1 J'aime

Thank you a lot for that,

I would like to know how to integrate Angular to my project, ( I know how to code a website on Angular, but I’ve never used it inside jsp files. ). I tried only integrating <script src=""></script>
And the code you gave me.
But i have some problems.

So could you explain how to add angular to a project and the way to add the code you gave me.

Thank you a lot , it’s really helping me.

see files carefully, it is angularjs directive which i shared, you don’t have to add any angularjs core files etc,

what issue you are facing?

I’m facing a : Uncaught ReferenceError: angular is not defined
In the web console

share screen shot or we can connect remotely

I Siddique, So i’ve put your code inside the Index.jsp
Just like that :

And here is the error I get :

If you want to connect remotely, contact me in private messages

if you follow the gist as it is, let me know if it didn’t work

Hello Siddique!
I have follow your code (and architecture) and everyhting is working well.
Thank you for helping me so far.
I will mark it as « Solution »