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: http://www.someurl.com/index.jsp?person=Bob

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?

Thanks!

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”
class=“com.forum.Administrator”/>

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:


redirect.jsp

<%

String pg = “somepage.jsp”;
session.setAttribute(“companyname”,“IBM”);
response.sendRedirect(pg);

%>


somepage.jsp

<html>
<head>
<title>Some Page</title>
</head>

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

</body>
</html>