• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to fetch Login_Id/User_Id to a JSP page

 
Vikas Satish Kapoor
Greenhorn
Posts: 4
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
I am working on an assignment related to JSP where I need to add a functionality according to which whenever a user clicks on a hyperlink, a page opens where there is a welcome message being displayed such as WELCOME user_id where user_id is the one which user entered when he/she logged on to the system. Please help me find a way to do it.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That greatly depends on what you mean by "log into the system".
 
Vikas Satish Kapoor
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The application will be put on the server and a link pointing to it will be shared through e-mail to a group of users. Whenever a user clicks on the link, there will be a welcome screen with display text as WELCOME Login_Id or WELCOME User_Id or WELCOME Email_Id where Login_Id/User_Id/Email_Id are the Ids which user enters while logging on from client side. Any one of these Ids will do. In case of Login_Id/User_Id, they are the ones the user enters while logging on to the client side terminal.
 
Pongsakorn Semsuwan
Ranch Hand
Posts: 34
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is just a concept that might help you understand a high level flow.

Firstly, your link has to have parameters in it and point to a Servlet. (e.g. point to www.yourwebapp.com/WelcomeServlet?userId=xxxxx )

The servlet read your variable using request.getParameter("userId") and does some backend stuff ( query DB, check permission , whatever )
and then redirect back to your page which is a screen that will show your data and welcome message (welcome.jsp)

In welcome.jsp you just use request.getAttribute to get value of your variables from a servlet



and I would recommend you to read and understand jsp taglib and the MVC concept for better idea of how to deal with data.

 
Mohammed Javeed Basha
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
set the loginid or userid in session object like this
String username = request.getParameter("username"); {where username in double quotes will be the name of the input type tag}
HttpSession session = request.getSession();
session.setAttribute("userid",username);

In welcome page you can retrieve like this
String UserName = session.getAttribute("userid");

or

through requestdispatcher you can forward to welcome.jsp like this
request.setAttribute("userid",username);
rd.forward(request,response);

In welcome page you can retrieve like this
<%=request.getAttribute("userid")%>
 
Tim Holloway
Bartender
Posts: 18408
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There isn't any such concept any more of "logging into the system". That's for mainframes and minicomputers pre-Internet.

You can log into the Network if you have a LAN connection and a LAN account. You can log into the webapp. But webservers are not time-share servers, and even if you are logged into the webserver machine itself as a shell account user (time-share login), that doesn't automatically log you into any of the web applications.

Your email client login has (unless defined otherwise) nothing at all to do with your network login or your web application logins. The only way to email a generic HTML link and get a user's "login information" to come up on the page that that link brings up is if you have set up a Single-Signon (SSO) security system and connected the webapp security Realm to the SSO services. And even then, that won't work for people who check their email from outside of the corporate LAN unless they're on a VPN.
 
Vikas Satish Kapoor
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for all the response I got and I appreciate the way you people are helping me to resolve the issue.
However, the main issue still holds which I would try to explain in more detail here.

1. The core of my problem is to get the user_id/email_id from the user without making him/her input it anywhere. i.e., the user does not inputs anything such as login, username or password into any HTML form tag. The functionality is pretty much as follows:-
The user logs on to the computer -> Logs in to his/her email client -> goes to inbox -> goes to the email waiting to be read -> in the contents of that email, there is just some text and then there is a hyperlink (pointing to an application which is deployed on a corporate LAN server) and nothing else. The user does not inputs any thing there,just reads the text and clicks on the hyperlink. -> however when the user is taken to the application page, there he finds a welcome message displaying WELCOME User_id or WELCOME Email_Id.

2. It is a corporate LAN network so it can be assumed that the Login_Id = User_Id = Email_Id. And moreover the application is not being put up on a web server, its a corporate LAN internal server.

Hope you guys will now get a clear understanding, and my apologies for not explaining it as clearly before.
 
Tim Holloway
Bartender
Posts: 18408
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's a web page, it's a web server, not a "LAN" server, which is a meaningless term. Servers come in all sorts of varieties, but it's the protocol that defines what kind of server it is, not what the server is attached to or what type of physical machine the server software is housed in. Whether a web server is for LAN use only, open Internet use, or both, it's still a web server, not a "LAN Server", file server, print server, Exchange Server, Active Directory Server, etc., etc., etc. Those items are simply the software server programs that may or may not be installed and running on a given server machine.

I'm afraid I cannot assume that the same user ID applies everywhere. It's usually easier when it does, but some shops are more consistent than others. It's purely what local practices and standards dictate, not a fundamental architectural law that I can take for granted.

If you're running an all-Microsoft shop, you can probably work out an Exchange plugin that will customize each user's copy of their email with their respective LAN login ID in the URL. Whether this is a good idea or not can be debated, but once again, that's up to local usage. What you can also do, however, is visit each LAN user's machine and switch on a special IE setting that appends a non-standard HTTP header containing the user's current LAN security credentials so that a "one-size-fits-all" URL can be used instead. If you do this, you also need a Windows-friendly SSO security Realm installed in the web server and in control of the webapp containing the JSP in question. That particular protocol is not a universal standard and applies only to Windows machines running IE on a LAN (unless someone has recently added it to the Apple web browsers). And even then the requisite IE function is switched off by default for security reasons.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!