Just wandering if anyone could help me out with a quick fix.
I'm looking for a quick simple example of JSP2.0 with JSTL or EL to connect to a Bean.
I have seen examples of how you retrieve data from a Bean but I was wondering if someone could throw in a quick example of populating a Bean, say for a registration page
of a site or something.
I assume that you mean after submitting a form? If so, then this is something that should be done in a servlet rather than a JSP. You could use <c:set> for this in a JSP, but submitting form data directly to a JSP would be considered a poor practice.
You can use the (legacy) jsp:useBean for that. But I agree with Bear that it should be done at in a servlet. That's the right approach nowadays. There are utilities and frameworks available which can populate beans for you 'automagically', for example Apache Commons Beanutils. If you want to do it at a bit higher level, consider JSF or Struts. In both MVC frameworks you've only 'action beans' and there is no need to write a servlet yourself.
Bear Bibeault wrote:I assume that you mean after submitting a form? If so, then this is something that should be done in a servlet rather than a JSP. You could use <c:set> for this in a JSP, but submitting form data directly to a JSP would be considered a poor practice.
So basically the only was is to use the old
There's no way of accessing a Bean directly from the JSP and setting the property?
OK, just wondered if JSP/Servlet had a way of accessing Beans directly (JSF style)
Cheers
Bauke Scholtz
Ranch Hand
Joined: Oct 08, 2006
Posts: 2458
posted
0
JSP/Servlet is just a basic API. JSF API extends JSP/Servlet with seamless bean-mapping like that.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.