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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:16:25+00:00 2026-05-20T13:16:25+00:00

I am using jsp and struts2, and I have the following scenario: <s:form> <s:hidden

  • 0

I am using jsp and struts2, and I have the following scenario:

<s:form>
<s:hidden name="empId" value="123"/>
<s:textfield name="employee.name"/>
<s:submit action="save"/>
</s:form>

When this form is submitted, the OGNL expression employee.name (equivalent to getEmployee().setName()) gets executed before “save” method. And, the value for “empId” is not available inside the method getEmployee(). The value for “empId” is available only inside the “save” method. Is it possible to get the value of “empId” inside getEmployee()?

Following is the code in my Action class:

public String save() {
  //empId is available here
  return SUCCESS;
}

public Employee getEmployee(){
  if (employee == null){
    //empId is not available here
    employee = employeeService.get(empId);
  }
  return employee;
}
  • 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-20T13:16:26+00:00Added an answer on May 20, 2026 at 1:16 pm

    First, I assume that you do have a setter for the empId field (you didn’t show one) and that your problem is that the order in which the parameters are being set is arbitrary.

    There is an option for the ParametersInterceptor to force it to set top-level properties first. You can enable it by customizing your interceptor stack to define the parameters interceptor with the ordered property set.

    <interceptor-ref name="params">
        <param name="ordered">true</param>
    </interceptor-ref>
    

    Then, in your action class, change the setEmpId method to:

    public void setEmpId(Integer empId) { // or whatever type it is
        this.empId = empId;
        employee = employeeService.get(empId);
    }
    

    As an alternative to the setter approach, you could also create a type converter for the Employee class and then change your form to:

    <s:form>
        <s:hidden name="employee" value="123"/>
        <s:textfield name="employee.name"/>
        <s:submit action="save"/>
    </s:form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following jsp file fragment using struts2 tags doesn't show the textfield label. How
I've got the following jsp page and I'm using struts2-jquery-plugin-3.1.1 <script type=text/javascript> function openDialog()
In a web project using jsp, I have following requirement Upload a file (say
I'm Using Struts2 in jsp page i have iterator values for checkbox. how to
we are using Struts2 in our code and I have scenario where I need
I have the following code to do a doubleselect using Struts2 and the jquery
I am using struts2 and hibernate. I have a jsp page which is loaded
Hi: In my jsp page,I have a form to add/update a nested object using
I'm using Java+struts2+JSP as the web application framework. I have to pass some huge
I am using Struts2,(jsp) to design page , I need three button on sing

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.