This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Struts and the fly likes getting form values on jsp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Frameworks » Struts
Bookmark "getting form values on jsp page" Watch "getting form values on jsp page" New topic

getting form values on jsp page

rick collette
Ranch Hand

Joined: Mar 22, 2002
Posts: 208
I try to get form attributes on a jsp page.
I did the following:
<% String myForAttribute = <jsp:getProperty
name="attributeA" property="ampleForm"/>; %>
But this does not seem to work.
I am wondering if my code is not right or there is a
better way?
Junilu Lacar

Joined: Feb 26, 2001
Posts: 6281

1. You can't embed a JSP tag in a scriptlet.
2. name is usually the attribute key of the bean you are trying to use and property is the name of the field in that bean. Thus, you would probably have something like
<jsp:getProperty name="ampleForm" property="attributeA">
3. You could use bean:write instead:
<bean:write name="ampleForm" property="attributeA">
4. If you need to use the value in a scriptlet, you could use bean:define
<bean:define id="attrA" name="ampleForm" property="attributeA" />
[ October 01, 2003: Message edited by: Junilu Lacar ]

Junilu - [How to Ask Questions] [How to Answer Questions]
rick collette
Ranch Hand

Joined: Mar 22, 2002
Posts: 208
It works actually.
[ October 02, 2003: Message edited by: rick collette ]
Have you checked out Aspose?
subject: getting form values on jsp page
It's not a secret anymore!