• 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

Setting Bean Property in JSP

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have a JSP with the following tags:



The setter doesn't work -- I just get



when I retrieve the property:



However, if I insert this scriptlet immediately after the "useBean" tag, the property is set and I can retrieve it using the above getProperty tag:



So, without scriptlet, output is:



With scriptlet, output is:



I really want to know what I am doing wrong and would appreciate any tips. One thing it has occurred to me to note is that this page is actually being called through RequestDispatcher.forward() in a servlet. I don't know if that matters or not.

I'm writing this in NetBeans 5.5, using the bundled Tomcat, 5.5.17.

Thanks.

mp
[ May 19, 2007: Message edited by: Michael Powe ]
 
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The param attribute of the jsp:setProperty action refers to the name of the request parameter...But you have a request attribute named user

String str = (String) request.getAttribute("user");



So if you want the jsp:setProperty to work,use something like this

or
In case EL is not enabled try this:


Regards,
Srikkanth.M
 
Michael Powe
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The param attribute of the jsp:setProperty action refers to the name of the request parameter...But you have a request attribute named user



Bingo. I knew I had to be doing something simple yet wrong. Thank you very much. You know, I posted this question over at Sun Forums twice, lots of looks and no answers. I've obviously been spending too much time with the wrong crowd!

It does not appear that I have any way of passing in attributes without resorting to scripting. That is annoying. I'll have to rethink my approach.

Thanks again.

mp
 
Sheriff
Posts: 67746
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 Michael Powe:
It does not appear that I have any way of passing in attributes without resorting to scripting.

How so? Srikkanth Mohanasundaram showed you a way to do it with the EL rather than scripting.
[ May 19, 2007: Message edited by: Bear Bibeault ]
 
Michael Powe
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:
How so? Srikkanth Mohanasundaram showed you a way to do it with the EL rather than scripting.



Sorry, probably careless usage on my part. I am thinking in terms of a purely tag-based approach and to me EL looks like script. Even though, it is not classed equivalently with scriptlets.

Thanks.

mp
 
Bear Bibeault
Sheriff
Posts: 67746
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
Modern JSP pages heavily employ the JSTL and EL to accomplish their task. Take the EL out of the mix and you've got very little left to work with.

The property manipulation tags and scriptlets are now considered passe and you should be focusing on JSTL and EL.
[ May 20, 2007: Message edited by: Bear Bibeault ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic