Solved

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

Posted on 2008-10-21
1
276 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 12

Accepted Solution

by:
marklorenz earned 500 total points
ID: 22766311
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
servlet example 11 59
Facing this issue for maven proxy setting 2 27
Java: The Public Class Main 4 46
hashmap order 17 42
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
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…

726 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