Set Session Variable using JSP

Okay, forgive me if I don’t explain this clearly, I’m new to the JSP environment.

What I’m looking to do is set a variable in the user’s session and use that variable on several dynamic jsp pages.

For example:

Page renders:

Welcome [person],

Now the user clicks on any link on the site and I can still pull the [person] variable from the session.

Any thoughts?


The way I normally do it is like this. I put the object which is holding the value ‘Bob’ into a bean. This can be your own bean or a Vector or a String.

<jsp:useBean id=“admin” scope=“session”

I put this at the top of the page where I first start the session and every page that I need to hold the session.

Thanks for the response. I tracked down a quick and easy way to do this, thought I’d share:



String pg = “somepage.jsp”;



<title>Some Page</title>

Welcome <font color=“red”><%= session.getAttribute(“companyname”) %></font>