★ wanayoo — archive 1999 http://developer.java.sun.com/developer/qow/Nouvelle recherche | Portail wanayoo
Java Technology Home Page
A-Z Index

Java Developer Connection(SM)
Question of the Week

Downloads, APIs, Documentation
Java Developer Connection
Tutorials, Tech Articles, Training
Online Support
Community Discussion
News & Events from Everywhere
Products from Everywhere
How Java Technology is Used Worldwide
Print Button
 

Question of the Week No. 100

Researched by Dan Gross

Question of the Week presents answers to key questions posed by the developer community. The intent is to pass this important, but not always easy-to-find, information on to Java Developer ConnectionSM (JDC) members. The questions are selected from the JDC Forums generally because: they are frequently asked, they are significant or timely, or the answers are not easily accessible.

chiclet5.gif Topic:  

What does the property="*" mean?

chiclet5.gif Question:  

In a JavaServer PageTM (JSP), I see the "*" in the setProperty tag. Can someone explain this to me? I can't find any specific documentation about this. Why is the * used? Are there any other valid values for this property?

chiclet5.gifAnswer:

The JSP setProperty tag with a "*" indicates that all properties in the JSP page will be set to its respective method in the bean. In other words, the "*" is a wildcard that copies all similarly-named parameters into the bean. If the "*" is there, then all the inputs in the JSP will be stored in the bean. You can also individually store inputs. Here is an example:

If you have:

 
<jsp:setProperty name="mybean" property="*" /> 
and you have the following Submit buttons:
 
<INPUT TYPE ="TEXT" NAME="login" value=""> 
<INPUT TYPE ="PASSWORD" NAME="password" value=""> 
Then you would have to write a corresponding method in the bean with the same name:
public String value; 
public String password; 

void setLogin(String value){ 
	login = value; 
} 

void setPassword(String value){ 
	password=value; 
} 
Note that in the setLogin, the "L" is capitalized. This is crucial. If this is not capitalized in the bean, then the setProperties will not automatically call the method in the bean.

For more information:

JavaServer PagesTM Technology

JavaBeansTM

JSP Architecture Quiz, including source code, which uses property="*".

Many thanks to JDC member chetan and mozkill for contributing to this answer.

Note: If you have a question to which you need an answer, try the JDC Forums. You can read through the existing topics, or with your free JDC membership, you can post new messages or threads.


duke150x107.gif Submit your comments or answers to this question here!


Include my JDC user id in my response

Please post new questions to the JDC Forums.
See what other members have said.


Print Button
[ This page was updated: 11-Aug-2000 ]
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first.
Sun Microsystems, Inc.
Copyright © 1995-2000 Sun Microsystems, Inc.
All Rights Reserved. Terms of Use. Privacy Policy.