Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting form values on jsp page

 
rick collette
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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?
regards,
 
Junilu Lacar
Bartender
Posts: 7581
52
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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">
instead.
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 ]
 
rick collette
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,
It works actually.
regards,
[ October 02, 2003: Message edited by: rick collette ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic