This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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: 61106
    
  66

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Issues with using <jsp:setProperty>