File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » JSP
Bookmark "Issues with using <jsp:setProperty>" Watch "Issues with using <jsp:setProperty>" New topic

Issues with using <jsp:setProperty>

jason zepris

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

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

Joined: Jan 10, 2002
Posts: 63852

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] [About Bear] [Books by Bear]
jason zepris

Joined: Jun 25, 2011
Posts: 8
Ah... ok thanks for the insight.
I agree. Here's the link:
subject: Issues with using <jsp:setProperty>
It's not a secret anymore!