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.
[ May 19, 2007: Message edited by: Michael Powe ]
String str = (String) request.getAttribute("user");
So if you want the jsp:setProperty to work,use something like this
In case EL is not enabled try this:
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.
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.
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 ]