Solved

How can I populate a bean from the parameters of an HttpServletRequest?

Posted on 2008-10-21
1
269 Views
Last Modified: 2012-05-05
I am using extjs to submit form information to a servlet. The parameters are named whatever I want, so let's say "id"="123" and "names[0]"="abc".

I want to populate a bean using that info. Let's say the bean is something like:
  class SomeBean {
    int id;
    List<String> names;
  }
I want to populate that bean by doing something like
  SomeBean bean = PopulateBean(request,new SomeBean());
so that bean.id=123 and bean.names is a list containing one entry which is "abc".

I know that I could manually do it, but I would hope that there was a general interface for this given that all the different frameworks like JSF and stripes and struts all do this sort of thing (although the old struts didn't do it very well for lists of lists of lists.).


0
Comment
Question by:HappyEngineer
1 Comment
 
LVL 12

Accepted Solution

by:
marklorenz earned 500 total points
Comment Utility
Is this what you're looking for?

In order to populate the bean, first create the bean, then call the populate method.
http://www.cs.fiu.edu/~downeyt/cgs4825/beans.html

HTH, Mark
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Java virtual machine monitoring tools 3 39
countX 22 68
parentbit challenge 3 50
firstChar challenge 13 82
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now