consider i have this bean

private string name = "fadi";
public String getname()
{
return (name);
}
public String setName(String name1)
{
name = name1;
return (name);
}

Now I have jsp file..

<%
beanid.setname("lol");
beanid.getname();
%>

Now with this code name was fadi, i changed it into lol. Now I want to change it back to the original one. I dont want to do it by calling beanid.setname("fadi"); .. is there any other way?? thank you very much.

I dont want to do it by calling beanid.setname("fadi"); .. is there any other way??

Well you could use the <jsp:setPropery> tag, but may I ask what you are trying to achieve with it ?

yes i can tell you. I have dictionary of words stored as array string ..

"ADD","DELETE" and so on..

I have a form where user enters words he wants to translate
say he adds ADD and his translation insert..
now array[0] is changed to insert ..
but in case he then deletes the the record( record that add = insert in the database), I want the array[0] to be back equal to ADD.

This is assignment I have. I also have to use getname(0) for add buttons..
so in case he changed it to insert, button value is insert...

basically i want to reset the beans into their original values in case of a record being deleted from the database.

Create an instance of jsp bean with session scope and set value for each field once record after deletion of record in your controller.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.