This stems from trying to use a bean to pass data, so really I just need to verify exactly what setProperty does, and if it does something in test1.jsp or test2.jsp.
I tried bean scope = request, session, application. I tried sticking the EL inside a <c: out> tag. I tried moving the jsp:setProperty up and down. Nothing worked.
Testing with Java6 in Eclipse 3.5 running Tomcat 6 with Firefox 3.5.
See the JSP FAQ which covers this extensively. Pay particular attention to how your deployment descriptor is declared.
Yes, my plan is to do JSP to servlet. I'm back to the question I've seen posted a few times where folks are trying to get the html form to auto-populate the bean, and send that to the servlet. I've got the JSP-servlet communication down fine. But I'm really not understanding how/when the following line gets executed, and if it doesn't really load up a bean with matching param values, what does it do?
<jsp:setProperty name="workorder" property="*" />
So I thought I could easily evaluate the bean using a 2nd JSP page. But that's proving difficult as well. Longer-term, I thought if I need to use the setProperty in the 2nd jsp page, I could auto-populate it then forward it to the servlet. But I'm not sure if that will work.
Keri Mathis wrote:Yes, my plan is to do JSP to servlet.
trying to get the html form to auto-populate the bean
These two statements are in direct conflict.
You either post to a servlet, or post to a JSP. If you are doing the former, the <jsp:setProperty> tag is obviously not available. If you are doing the latter just to be lazy and use the <jsp:setProperty> tag, well, ...
If you want something that can do the same job, but run in servlet code, check out the BeanUtils.populate() method of the Jakarta Commons BeanUtils project.
I thought if I need to use the setProperty in the 2nd jsp page, I could auto-populate it then forward it to the servlet. But I'm not sure if that will work.
As I indicated above, that's creating a lot of artificial contortions, extra overhead, and violation of best practices, just to be able to use <jsp:getProperty>. Does that really make sense?
I saw you referenced using a Map wrapper, but was not clear how that worked either. But the BeanUtils.setProperty() may be just the thing if I can pass a new bean and the request.getParameterMap(). Thank you for the feedback and the tip.
The code :
is converted to this at compile time:
here this line:
finds attribute names from request object and calles appropriate setter method on the work order bean.
You have done everything right except place this code:
Means you have to place this code when you have bean attribute values set in request object. Means this code should run after your form submission on test1.jsp not before form submission. So your test1.jsp would be:
and test2.jsp would be: