Problem receiving variables from a servlet

In doPost I set a variable, req.setAttribute("uname",user); then I forward it,

req.getRequestDispatcher("/page.jsp").forward(req, resp);

I'm trying to access this variable I set in my JSP. <%=uname%> gives me an org.apache.jasper.JasperException: Unable to compile class for JSP error. <%request.getParameter("uname"); %> gives me null.

In my servlet I print out uname and it does print out the correct user name. Can anyone see what I am doing wrong?

[489 byte] By [ner0a] at [2007-11-27 4:43:15]
# 1
> what I am doing wrong?Attributes != Parameters.
BalusCa at 2007-7-12 9:54:59 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Well I got it to work with request.getAttribute() but I think <%=uname%> should still work and would prefer to use that, since I'm trying to pass this variable into a js function. Is there any reason that wouldn't work?
ner0a at 2007-7-12 9:54:59 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

<%= uname %> looks for a scriptlet variable on the page called "uname"

That has nothing to do with request attributes.

If you have a JSP2.0 container (Tomcat 5) then the EL expression ${uname} is pretty much equivalent to request.getAttribute("uname") (its actually pageContext.findAttribute("uname"))

Passing this variable into a js function?

By this I presume you mean "generating static javascript code onto the page"

You remember that java/jsp code only runs on the server right?

evnafetsa at 2007-7-12 9:54:59 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
I looked into pageContext and got it to work using<% String user = (String)request.getAttribute("uname");pageContext.setAttribute("user",user); %>and in my js I can call <%=pageContext.getAttribute("user") %>and it works.
ner0a at 2007-7-12 9:54:59 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...