using javabeans to request dynamically created form fields

Posted on 2008-01-26
Medium Priority
Last Modified: 2010-03-30
hey guys,

I want to use java beans
I have a form in which I have dynamically created fields. I want to get the values of those fields and put it into a database.

the name of the fields is dynamically created
Question by:sonu19
  • 2
LVL 15

Expert Comment

ID: 20751813
Pass your request params into your javabean, and you'll have access to all of your submitted data.

Accepted Solution

mohammedf earned 750 total points
ID: 20753228
make something like this:
Enumerator names = request.getParametersNames();
while (names.hasNext()){
   String value=request.getParameter(names.next().toString);
    // add value to database

Open in new window


Expert Comment

ID: 20753843
send dynamically created fields with types and db column name and then create your sql statement with these info dynamically.

LVL 15

Assisted Solution

bpmurray earned 750 total points
ID: 20754059
Watch out - the javabean can't see your request. You have to handle it in your DoPost (or DoGet) method, so it would be something like this code. Of course, you haven't been very specific as to how you want to use this stuff, but I'm assuming it's to process the values. If you want to set the values, you'll have to update the response too.

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    Debug.log(this, "doPost", "new request");
    Map requestNameValuePairs = request.getParameterMap();
    MyJavaBean mjb = new MyJavaBean();
    // and so on
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    doPost(request, response);

Open in new window


Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month3 days, 13 hours left to enroll

599 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