The below are my findings:
To answer the second part
2) response.sendRedirect("userLogged.jsp");
and
${param.name} in userLogged.jsp
Here the response is already comitted and you are trying to fetch the parameters(request).
Description:
request,response objects are
thread safe and synchronous in nature(Apache tomcat6.0).Once response is
given to the client we cann't retrive.
(go through sendRedirect/forward)
EL:Elmination to
java syntaxs in
JSP
It checks the syntax vaildity not the existence of variable.
-->Translation (which involves compilation):
The abstract class javax.servlet.jsp.el.ExpressionEvaluator has a method evaluate(java.lang.String, java.lang.Class,
javax.servlet.jsp.el.VariableResolver, javax.servlet.jsp.el.FunctionMapper) checks for syntax error.
--->RunTime:
At runtime the
String representing the expression is sent to a method called resolveVariable()
which uses javax.servlet.jsp.JspContext 's public abstract java.lang.Object findAttribute(java.lang.String);
the returned object is sent to the outputstream via an out.print();
Note:Even if the variable doesn't exists sensible defaults are provided.
Adding on this finAttribute checks through the scopes in the following order.
page,request,session,application.
To answer the first part about scopes:
1)session.setAttribute("currentSessionUser", user);
and
<jsp:useBean id="currentSessionUser" class="examplePackage.UserBean" scope="application">
${param["username"]}-->Map of ServletRequest paramter.(You have already comitted response check forward/sendredirect you will get solution.)
${sessionScope.currentSessionUser.username}-->you are targeting the session scope,Which you have already set so is the result.
Conclusion:
-->sendRedirect will evades
up the request objects.
Please let me know if I am missing something.