0

I have a log in page for users, which if the login name is valid takes user name and puts it into

a session.setAttribute(“user”, String);

the user then gets redirected a userspage.jsp.

At that page I can get the “user” using :

<% getAttribute = (String)session.getAttribute("user"); %>
the user is <%= getAttribute %>

I can easily add a suffix String alluser = user+ .html

I want to use it in <a href = “alluser” > some text </a> but obviously this would equate to literally alluser getting an can’t find alluser page. I want to use the value of alluser with a method which replaces <a href with something that allows the use of the alluser value

something like
response.sendRedirect(user_name+".jsp");
what other methods could I use ?

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by luddite
0

You mean that this:

<% 
String link = "";
String user = (String)session.getAttribute("user"); 
if (user!=null) {
  link = user + ".jsp";
} else {
  // do something else since the user is not in the session
}
%>

<a href = "<%=link%>" > some text </a>

Is not what you want?

0

javaAddict

exactly - thanks very much it was the "<%=link%>" i was having trouble with , its working just tested on tomcat; some how before it wasn't - if off for a calamine tea!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.