Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Struts : Accessing a javabean inside a JSP

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
this is my problem: i've created a JavaBean inside an Action and i've added the bean to the session. I want to display the value of the bean's property 'username' in the jsp pointed from action (i.e. the jsp on wich the action execute forwarding)
into the JSP the property results empty, but inside the action relate i can access correctly to it.
Here's my situation:
UserBean userBean; // only private String username; with get()/set()
Login.jsp - LoginAction.java // the JSP + the action related
into LoginAction.java I perform:

LoginAction forwards to Search.jsp , on which i write:

None of three access to bean returns a String different fron "".
But in the action related to Search.jsp i perform:

And it goes well...
Conclusion: i cannot access to bean inside jsp, but i can into Action... Any tips?
Sorry for my poor english!
Thanks in advance,
Nerbo
[ April 22, 2004: Message edited by: Il Nerbo ]
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Nerbo
It seems you are totaly new to Struts framework. If you are creating the bean inside the Action Class then there is no need of defining it again in the jsp. Also if you simply want to display it in the jsp page then simply send the username to the jsp, and in the jsp use request.getParameter("username") to access it and display it in the browser.
 
Il Nerbo
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by The Big Barber SSSS:
Dear Nerbo
It seems you are totaly new to Struts framework. If you are creating the bean inside the Action Class then there is no need of defining it again in the jsp. Also if you simply want to display it in the jsp page then simply send the username to the jsp, and in the jsp use request.getParameter("username") to access it and display it in the browser.


I've found my (stupid) error. Instead of

I must write

It was not involving Struts, only servlet things.
Therefore, the bean that i must create is not a Struts bean, simply a classic bean.
Thanks!
 
It's a tiny ad only because the water is so cold.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic