I am new to J2EE and I am asked to do this:"Display two bean properties in a JSP file, the value of the username should be retrieved from the request.getRemoteUser();"
I got:
Expand|Select|Wrap|Line Numbers
- <%
- String user = request.getRemoteUser();
- %>
- <jsp:useBean id="userbean" class="mybeans.UserinfoBean" scope="session" />
- <jsp:setProperty name="userbean" property="username" value=user />
- <jsp:setProperty name="userbean" property="branchname" value="???" />
Expand|Select|Wrap|Line Numbers
- The logged-in username is:
- <jsp:getProperty name="userbean" property="username" />
- He/she is in branch:
- <jsp:getProperty name="userbean" property="branchname" /> .
- <br />
- <%
- out.println(user);
- %>
The logged-in username is:He/she is in branch:???
sydney
It seems that I have got the string user = sydney, and the expression tag could print that out. However I couldn't set that value into the JavaBean...
BTW I've tried using the ${user} EL
but it didn't work as well.
Thanks in advance!
Sincerely yours,
Matt