aspose file tools*
The moose likes JSP and the fly likes JSP 2.0 JSTL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP 2.0 JSTL" Watch "JSP 2.0 JSTL" New topic
Author

JSP 2.0 JSTL

Kevin P Smith
Ranch Hand

Joined: Feb 18, 2005
Posts: 362
Hi

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.

Something simple like this:-


JSP
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
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.
Kevin P Smith
Ranch Hand

Joined: Feb 18, 2005
Posts: 362
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
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://aspose.com/file-tools
 
subject: JSP 2.0 JSTL
 
Similar Threads
Repeated code in Servlet and Bean
Simple EL code is not working
Getting the name of the requesting page
bringing up simple form in spring
Struts 1.2.4 File Upload - Form File is null in action