• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to access Bean

 
Ranch Hand
Posts: 1162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67748
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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="<c:out 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
Sheriff
Posts: 67748
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are forwarding to a servlet from a JSP? Please be explicit on the chain of events.
 
Can you shoot lasers out of your eyes? Don't look at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic