Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9289211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:07:14+00:00 2026-06-18T20:07:14+00:00

I have a form which has 30 different fields. As passing them all to

  • 0

I have a form which has 30 different fields. As passing them all to the controller need to have an attribute for each along with a pair of getter, setters.

I am going to make the form fields as an object and send the object to the controller.

I am using the following code *but some people suggest its a bad practice to call a java method from jsp and use JSTL instead, but do not know how to implement it using JSTL.
Is there any other method to do it?
*

My JSP

 <s:form>
 code to implement form goes here
 </s:form> 

<jsp:useBean id="obj" class="com.User"/>

    <jsp:setProperty property="*" name="obj"/>

      <%
         String myoutput = myController.Xclass(obj);
         out.print(myoutput);
         if(myController.Xclass(obj).equals("output"))
            {
               out.print("The form is successfully submitted.");
            }
      %>

The controller

  public String Xclass(User obj){
           return "output";
        }

To clarify my class diagram is a following:

User Class {
 all the attributes and getters setters
}

myController class extends User {

    public String XClass(User obj){
       ... work on the inputes ...
      return "output";
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T20:07:16+00:00Added an answer on June 18, 2026 at 8:07 pm

    If the number of action properties is the issue, expose a POJO manually, or use ModelDriven.

    Doing it manually is simple, for example:

    public class UserController {
        private User user; // Plus public getter and setter
    }
    

    Then in the JSP you can refer to User properties by name:

    <s:form ...>
      <s:textfield key="user.firstName"/>
      ...
    

    Using ModelDriven is theoretically even easier, since it’s put on the stack automagically. It can be tricky to make sure new models are instantiated only when required, but basically (from memory):

    public class UserController implements ModelDriven<User> {
        private User user;
        public User getModel() { return user; }
    }
    

    Use the User properties directly in the JSP since the User is pushed on the stack:

    <s:form ...>
      <s:textfield key="firstName"/>
      ...
    

    Similarly, on form submission, a model is created and used as the first target of methods.

    Please remember that you never send objects to the Java side: you always, and only, send strings (from normal HTTP form submissions). There may be magic on the server side that transforms those strings into objects, but it’s just that: magic. Magic and hope.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form, which has a few different submit buttons on it all
I have a form on a website which has a lot of different fields.
I have a LWUIT Form which has 3 containers, each with its own content.
In simple terms I have a form which has three identical entry fields. The
I have a form which has a RichTextBox docked to the left and DataGridView
I have a form which has three inputs when the page loads -- 2
I have a form which has elements in a couple of divs. Based on
I have a form which has only tab control in it. I want to
I have a form which has a Combo Box Control. I have selected the
I have WPF Form which has many buttons with the same code. Appearance of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.