Access credential in JSP

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Access credential in JSP

#1

Postby Segi » Tue Apr 06, 2021 9:47 pm

In my server side Javascript scripts, I can get a credential value by doing

Code: Select all

system.securityManager.getCredential("REALNAME")
Is there a way to read the REALNAME credential from the server in my JSP script?
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

Re: Access credential in JSP

#2

Postby Jon » Wed Apr 07, 2021 11:43 am

You can access the API via the form interface which can be obtained in a JSP using..

Code: Select all

<% UFSFormInterface form = (UFSFormInterface) session.getAttribute("FormInterface"); %>
Then you should be able to use..

Code: Select all

<% String name = form.system.securityManager.getCredential("REALNAME");%>
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Re: Access credential in JSP

#3

Postby Segi » Wed Apr 07, 2021 3:23 pm

Jon,

Thanks but I am getting an error with that code:

Code: Select all

<%@ page language="java" import="com.ebasetech.xi.api.*" %>
<% 
   UFSFormInterface form = (UFSFormInterface) session.getAttribute("FormInterface");
   String name = form.system.securityManager.getCredential("REALNAME");
%>
NAME IS <%= name %>
the error in the server logs is:

Code: Select all

Wed Apr 07 08:18:17: ERROR Error running include HRHomepage/index.jsp Unable to compile class for JSP: 

An error occurred at line: [2] in the jsp file: [/HRHomepage/index.jsp]
UFSFormInterface cannot be resolved to a type
1: <%@ page language="java" import="com.ebasetech.xi.api.*" %>
2: <% UFSFormInterface form = (UFSFormInterface) session.getAttribute("FormInterface");
3:    String name = form.system.securityManager.getCredential("REALNAME");
4: %>
5: NAME IS <%=name%>
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Re: Access credential in JSP

#4

Postby Segi » Wed Apr 07, 2021 3:31 pm

This code works:

Code: Select all

<%@ page language="java" import="com.ebasetech.ufs.kernel.*" %>

<% UFSFormInterface form = UFSFormInterface.getFormInterface();

   String name = form.getSystem().getSecurityManager().getCredential("REALNAME"); 
%>
NAME IS <%= name %>
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

Re: Access credential in JSP

#5

Postby Jon » Wed Apr 07, 2021 4:13 pm

Glad you have it working. You would have needed an extra import to get the first example working, plus probably getSystem() instead of system.
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Re: Access credential in JSP

#6

Postby Segi » Fri Apr 09, 2021 6:47 pm

Jon,

what about the $eb interface equivalent in JSP ? I would like to execute a client callable function on the server side from JSP by doing something similar to $eb.executeFunction() in JavaScript but in JSP. Is this possible ?

I looked through all of the interfaces in the docs at /ufs/doc/javadocAPI/index.html and the closest thing that I found is in the EbaseSystem.executeCustomFunction method but that doesn't appear to call a client side function.
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

Re: Access credential in JSP

#7

Postby Jon » Mon Apr 12, 2021 2:53 pm

No, you can't do this, it doesn't really apply. The $eb interface is available to client-side Javascript in the browser and executeFunction() then calls the server to run the function. With a JSP you are already running on the server. But I'm afraid there is no way to execute a Javascript function contained in a script from a JSP.
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Re: Access credential in JSP

#8

Postby Segi » Mon Apr 12, 2021 5:18 pm

Jon,

Thanks.

That's what I expected.

I ended up writing code in my JSP to run an SQL query instead of trying to call a server side script that does that.
0 x


Who is online

Users browsing this forum: No registered users and 7 guests