473,473 Members | 2,169 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to set a bean property using the value from a page?

121 New Member
Hello everyone.
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
  1. <%
  2.      String user = request.getRemoteUser();
  3. %>
  4. <jsp:useBean id="userbean" class="mybeans.UserinfoBean" scope="session" />
  5. <jsp:setProperty name="userbean" property="username" value=user />
  6. <jsp:setProperty name="userbean" property="branchname" value="???" />
Then I use:

Expand|Select|Wrap|Line Numbers
  1. The logged-in username is:
  2. <jsp:getProperty name="userbean" property="username" /> 
  3. He/she is in branch:
  4. <jsp:getProperty name="userbean" property="branchname" /> .
  5. <br />
  6. <%
  7. out.println(user);
  8. %>
I got the JSP output:
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
Sep 19 '07 #1
1 2388
mattmao
121 New Member
I got it:

value='<%= request.getRemoteUser() %>'


I forgot the key issue that JSP tags can be nested...
Sep 19 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Pat Kelley | last post by:
I am trying to feed database column data into a bean using JSTL expression language: <jsp:setProperty name="fileWrite" property="fileText" value="1"/> <c:set var="test" value="test"/>...
0
by: jenniferyiu | last post by:
Hi. I downloaded the bean builder and followed the steps told on http://java.sun.com/products/javabeans/beanbuilder/1.0/docs/guide/tutorial.html and the sample tools was created as the above...
61
by: Steven T. Hatton | last post by:
Stroustrup's view on classes, for the most part, seems to be centered around the notion of invariants. After a bit of adjusting to the use of yamt (yet another math term) in computer science, I...
3
by: Dave | last post by:
I think this is a simple struts question.... I want to display information on a page in a static way. That is, not as part of text elements. I can't find an appropriate struts tag to use. ...
2
by: nvidia1 | last post by:
Hi this is my first post but so far this is pretty good site. I have a file called index.html with the following code: <!-- index.html --> <html> <head><title>Student Registration...
0
by: jaisi | last post by:
What iam exactly trying to do is..saving the resultset in a bean.....and calling the bean in a servlet and forwarding it to jsp by setting the bean in the request scope; Now i have only one record...
1
by: hostel | last post by:
HTML PAGE <html> <body> <form action="second.jsp" method="get"> YOur name <input type=text name="name"> <input type=submit > </form> </body> </html>
1
by: sumantabardhan | last post by:
public class area { int id; public void setId(int id) { this.id=id; } public String...
2
by: illu1985 | last post by:
package area; import java.sql.*; import java.util.*; public class area { int id; public void setId(int id) {
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.