Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Array List - How Do I?

 
Ramaswamy Srinivasan
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I have a requirement where I am having around 12 parameters to be passed to the servlet from a JSP and then to the DB from the Servlet

Now My question is how can i use an ArrayList to do this task of updation?

Like say i want to store all the values in an ArrayList and then update it altogether to DB. Is there any way other than this, that would be better?

If so, where do i get some info on that?

Thanks a lot....

Your help is highly appreciated.

Cheers,
Swamy
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ramaswamy,

IMO, If the 12 parameters that you are passing are logically related, the best way would be to have an object with those parameters as instance variables, then you create an object, set those parameters as its properties, and pass it to any method that needs those.
In servlet, JSP environment, you can pass the object by setting it as a request scope attribute. Using an object instead of an Arraylist or Object[] in a case like this would make the code more readable.

cheers
Sonny
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic