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 ?

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?

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.