Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How can I get my form inside the arraylist?  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Netbeans in this project. I need to pass the typed information in the form using POST to an arraylist so that when the Servlet is called by GET, it displays a table with the data! But I'm totally new to programming and my knowledge only extends to creating simple forms using POST and receiving POST. Someone can possibly explain this or post a code that do this?

My codes are:


and

 
Rancher
Posts: 1832
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean you wish to store information retrieved in servlet in an array list?
 
Nate Lewis
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

"Do you mean you wish to store information retrieved in servlet in an array list?"
Swastik Dey



Yes, I wanna save this informations (name, email, phone) in an array list so i can retrieved and display with servlet!
 
Nate Lewis
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! To be specific I need to make a form (html5) where people can type name, email and phone number. Call a Servlet (POST) Save the data in Arraylist and if the Servlet is called directly (GET) it must display a table with the informations that were typed.
 
Rancher
Posts: 3385
38
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this data supposed to last for the session?
If so, you can store the ArrayList in the session (which you can get from the request object).

Since this is data represents something (maybe a User?) then it would make more sense to create a User class that holds these three pieces of data, and store that in the session.
 
Author and ninkuma
Marshal
Posts: 66535
160
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never use an array (or list) to store structured data. At minimum use a Map implementation, at best a custom class representing the structured data.

Why aren't you using JSP to create the HTML views?
 
Nate Lewis
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont have experience with coding with Servlets, the only thing I know is how to create the form. The rest is very difficult to me and I really need to understand this
Someone can show me an example off how can I do this? or a video where something like it its done.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!