• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

storing textfield values

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a jsp page that is created dynamically. The number of text boxes is created dynamically, and i don't know before hand how many there will be. I know that if I name the text boxes the same i can store the value in an array. My question is there anyway to do this using a bean. i.e. I have a bean that i am storing all the values in from the text fields using setters. But if all the text fields are the same name is there a way to store these values in an array in the bean.
Here is my jsp
<html>
<head><title>JSP Page</title></head>
<body bgcolor="#F0E9D7">

<jsp:useBean id="write" scope="request" class="Beans.WriteBean" />
<jsp:setProperty name="write" property="*"/>
<form action="index.jsp" method="post">
<input type=text name=email value="whaterver" size="15">
<input type=text name=email value="whaterver" size="15">
<input type="submit">
</form>
<%
write.writeFile(temp);
out.print(temp);
%>
test

</body>
</html>
and my bean is just a simple bean shown below
public class WriteBean extends Object implements Serializable {
private String fileName;
String email;

public WriteBean() {
}

public void setEmail(String name){
email = name;
}
public String getEmail() { return email; }

public void writeFile(String name){
try{
FileWriter out = new FileWriter("C:/Documents and Settings/Bbroschinsky/Desktop/"+email+".txt");
out.write("test for out");
out.close();
}catch(IOException e){
}
}

}
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look up the term "indexed property" with regards to JavaBeans.
 
Can you shoot lasers out of your eyes? Don't look at this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic