wood burning stoves 2.0*
The moose likes JSP and the fly likes Issues with using <jsp:setProperty> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Issues with using <jsp:setProperty>" Watch "Issues with using <jsp:setProperty>" New topic
Author

Issues with using <jsp:setProperty>

jason zepris
Greenhorn

Joined: Jun 25, 2011
Posts: 8
Hi guys just started learning jsp and am having issues with setting the values of my bean in a jsp page.


jsp page


Person.java


RegisterAction.java


So basically it seems like the setter method of the Bean is never called when the form is submitted because whenever I try to retrieve that firstName value it's always null irrespective of what I enter in the input field.

Anybody know what I'm doing wrong here?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

You're submitting a form to a servlet and then trying to get the submitted values from a bean in the session? No, that's not correct.

The fields from the form will be directly submitted to the servlet where you should retrieve them with request.getParameter() calls.

The useBean and setProperty stuff is kind of a holdover from 10 years ago before modern patterns for web applications arose. They're intended for use when submitting forms to JSPs rather than servlets, which modern practices no longer allow.

If you are new to JSP, I'd recommend reading this article to understand what JSP is all about, and this article to understand how modern web applications should be structured.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
jason zepris
Greenhorn

Joined: Jun 25, 2011
Posts: 8
Ah... ok thanks for the insight.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Issues with using <jsp:setProperty>
 
Similar Threads
JavaBeans and Servlets
Extracting data from a bean
Form processing using register.java but it doesn't show my hashmap errormessages
Error while validating the input
Simple jsp form