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 7068437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:19:25+00:00 2026-05-28T05:19:25+00:00

I m new to Struts2 and Hibernate. I am trying to save values from

  • 0

I m new to Struts2 and Hibernate. I am trying to save values from the form.
On submit the value of the textarea will be saved null;

My form is like this-

 <s:form action="saveComment">
                        <s:push value="ai">
                            <s:hidden name="id"/>
                            <table cellpadding="5px">
                                <tr><td><s:textarea name="description" rows="5" cols="60" theme="simple" />
                                    </td>
                                    <td> <s:submit type="image" src="images/sbt.gif"  >

                                        </s:submit>
                                    </td></tr>

                            </table>
                        </s:push>
                    </s:form>

and my Action Method is like this-

  public String saveComment() throws Exception {

    Map session = ActionContext.getContext().getSession();
    ExternalUser user = (ExternalUser) session.get("user");
    AIComment aiComment = new AIComment();
    aiComment.setAi(ai);
    aiComment.setPostedOn(new java.util.Date());
    aiComment.setPostedBy(user);
    aiCommentDao.saveAIComment(aiComment);
    return SUCCESS;
}
  • 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-05-28T05:19:26+00:00Added an answer on May 28, 2026 at 5:19 am

    Struts2 have build in mechanism to transfer your form values to your respected Action class all you need to do the following steps.

    1. Create property in you action class with same name as the form fields name and provide there getters and setters.

    Struts2 will match those action property names with the names of the fields being sent from the form and will populate them for you

    in you case all you need t do the following

    public class YourAction extends ActionSupport{
    
      private String id;
      private String description
    
      getter and setters for id and description fileds
    
       public String saveComment() throws Exception {
          //Your Method logic goes here
       }
    
    }
    

    So when you will submit the form it will contain id and description as form values.Struts2 interceptor (param in this case) will see your action class has these properties and will populate them before the saveComment() method will get executed.

    Hope this will give you some understanding.

    In short all these heavy work data-transfer/ type conversion is being done by interceptors behind the scene for you.

    read the interceptors details for better understanding

    1. interceptors
    2. parameters-interceptor
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to save a data in a simple form through Hibernate using struts
Im using Struts2 and Hibernate, trying to create a simple form to edit an
I'm trying to save 2 entities in AppFuse (Struts2, Hibernate and Spring) at once,
I am new to Struts . I downloaded Struts2 from its website. Now I
I'm trying to start a new struts 2 project using maven (struts2 blank archetype)
hi I am new in Struts2 and want to send parameter from one action
I am developing a new web application with Struts2, Spring and Hibernate as its
I am new to struts2 tiles. Here i am trying to execute 1 simple
I am new to struts/hibernate I downloaded an example from mkyong .. when i
i want to integrate Struts with Hibernate. I am new to these technologies. Infortunately

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.