• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to access Bean

 
Arvind Mahendra
Ranch Hand
Posts: 1162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I use a bean in my JSp like
<jsp:useBean id="userInfo" scope="request" class="com.beans.UserInfo" />

I tried accessing this in my servlet like:
UserInfo u1= (UserInfo)request.getAttribute(userInfo)

but it doesn't work. How can i have this bean be available in the servlet?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does UserInfo have a no args constructor?

Are you forwarding from your JSP to your servlet (if so, why?).
If not, request scope is probably not what you're looking for.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Arvind Birla:
but it doesn't work.

Does the keyboard burst into flames?

Seriously, "it doesn't work" doesn't tell us anything about your issue. What happened? What error did you get?
[ April 21, 2008: Message edited by: Bear Bibeault ]
 
Arvind Mahendra
Ranch Hand
Posts: 1162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
UserInfo is a bean that is populated with data that the user fills out in the form. On this page I just use the line below to display what he entered.
<jsp:useBean id="userInfo" scope="request" class="com.beans.UserInfo" />

The line above is used to display the data to the user before entering in the dbase like below.

value="<cut value="${userInfo.emailAddr}" />">


I need the bean in a servlet I forward to when the user agrees to having this data put into a Dbase.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are forwarding to a servlet from a JSP? Please be explicit on the chain of events.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic