Meaningless Drivel is fun!
The moose likes JSP and the fly likes Order of the setter methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Order of the setter methods" Watch "Order of the setter methods" New topic

Order of the setter methods

saran ram
Ranch Hand

Joined: Dec 13, 2002
Posts: 69
If I have a jsp file as below:

<jsp:useBean id="person" class="" scope="session" />
<jsp:setProperty name="person" property="*"/>


First Name: <input type="text" name="first" value="" ><br>
Middle Name: <input type="text" name="middle" value="" ><br>
Last Name: <input type="text" name="last" value="" >

<input type="submit" name="submit">

& .java file as


import java.util.*;

public class SaranUseBeanTest {

public String a = "";
public String b = "";
public String c = "";

public void setFirst(String value){
System.out.println("*****First: " + value);
a = value;

public void setMiddle(String value){
System.out.println("*****Middle: " + value);
b = value;

public void setLast(String value){
System.out.println("*****Last: " + value);
c = value;

public String getFirst(){
return a;

public String getMiddle(){
return b;

public String getLast(){
return c;

Now will the setter methods will be called in the same order as in jsp?
ie. setFirst,setMiddle,setLast.
Though it may not have any significant effect.
Just I want to clarify..
[ November 28, 2005: Message edited by: Bear Bibeault ]
C Broussard

Joined: Jun 18, 2004
Posts: 28
i'm only taking a stab at this. but i think it's totally dependant on how
they come across in the POST or GET. the webbrowser builds this based on the RFC specification for the http protocol. so you can not guarantee this order, since each browser is different. i wouldn't rely on it.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63870

the same order as in jsp?

What order? The JSP specifies no explicit or implied order.
[ November 28, 2005: Message edited by: Bear Bibeault ]

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Order of the setter methods
It's not a secret anymore!