on 03-06-2006 5:33 PM
The goal is to simply access the logged in user's information from a JSP page.
What we've done so far is setup an application on Basic Authentication. We deployed a simple JSP "application" with the Authentication. When we hit it, we get a logon prompt. So far so good.
Now the only problem is, I've been trying to retrieve the user information with the IUserFactory. However, I'm getting exceptions when I use them. I'm not sure if using the I* interfaces are acceptable in a simple JSP page so that's what I wanted to know.
Is my whole attempt in retrieving the IUser in a simple JSP incorrect or must I use a servlet or another component?
Thanks,
David
hi,
It is not necessary to use a servlet for this purpose.
But a simple java class with the variable for user details to be stored is enough.
1. create an object of the class and store the user information to this object(when user is logging initially)
2. Bind this object to the current Session.
HttpSession ses = request.getSession();
ses.setAttribute("someName",objectToBind);
3. Retrive the binded object and get the user info.
// in jsp latter when user details is needed.
userobj = ses.getAttribute("someName");
<jsp:useBean id="user" class="userobj" />
4. Now you can get the user information ...
thanks and regards,
arul sekar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
From the replies, I'm assuming that I can't use ONLY a JSP page then? We are currently just testing
using the Basic JRAAuthentication so it gives us a windows prompt for user / pw; we did not create
our own HTML login form. Only a simply JSP page. Here is what I have tried:
<% IUser user = componentRequest.getUser(); %>
Hello, <%= user.getFirstName() %>
And I get a 500 error with this message:
Application error occurred during the request procession.
Details: com.sap.engine.services.servlets_jsp.server.exceptions.WebIOException:
Error compiling [/UserLoginApp/login.jsp] in application [UserLoginApp]. The ID of this error is
Exception id: [001321FBCE1F00470000008B0000032000040E6B2E5D2B08].
It appears that perhaps I do need to make my own login page along with my own customized login
module to add the user to the session? I'm surprised that I would have to do that and the existing
login modules don't already do that?
David
Hello,
<b>Login and retrieve user data from database :</b>
Tha following will have sample code for login and retrieve user data.
http://www.daniweb.com/techtalkforums/nextnewesttothread35732.html
FOr more details on JSP to retrieve data, ple go thru it.
http://www.weblogic.com/docs/examples/jsp/index.html
http://java.sun.com/developer/technicalArticles/Programming/jsp/
HoPE It HElPS ... !!!
Thanks
VArun CN
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
David,
If you can provide more information on the types of errors / exceptions you are getting it would be helpful in guessing your problem.
<b>[The goal is to simply access the logged in user's information from a JSP page.]</b>
You can achieve this by putting a user information object in the session object. The general flow would be
1. Login page display. User enters credentials , clicks on logon button.
2. The authentication module is called.This verifies user credentials and then creates a new session for the user.Puts the information relevant to the current user in the session.Forwards the request to the page which displays the details after successful logon.
3. This page retrieves the details of user from session and displays it.
Hope this helps.
~ Amol
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.