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

  • Home
  • SEARCH
  • 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 8403225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:17:12+00:00 2026-06-09T22:17:12+00:00

I have some code in JSP as below: <c:iterate name=list id=payment index=idx> <tr class=gRowEven

  • 0

I have some code in JSP as below:

<c:iterate name="list" id="payment" index="idx">
<tr class="gRowEven"
  _paid="<c:write name="payment" property="paid"/>">

Now my problem is that I want to call a method in a controller based on the variable _paid. I can do a request.setAttribute("_paid", _paid)

I am assuming it would work. But I am not supposed to do it that way. So I was wondering if there is any other way to do it?

  • 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-09T22:17:13+00:00Added an answer on June 9, 2026 at 10:17 pm

    You can pass that value to a hidden input field (on form submit)

    <form action='your controller' method='POST'>
        ...
        <input type='hidden' id='newfield' name='newfield' value=''/>
    </form>
    

    then you controller can retrieve its value (using request.getParameter(‘newfield’), or a MVC framework provided method)


    Or simply append to the URL if your controller takes GET request


    By the way,

    request.setAttribute("_paid",_paid);
    

    probably won’t work for you. Because this call is only executed when page is loaded, not when you submit the page. Also, when you submit a page, it will have a new fresh request


    Edit: (this is what I meant by saying ‘pass that value to a hidden input field (on form submit)’)

    <script type='text/javascript'>
        function updateHiddenField() {
            var trPaid = document.getElementById('trPaid'); //assume tr field's id is trPaid
            //if tr doesn't have an id, you can use other dom selector function to get tr 
            //element, but adding an id make things easier
            var value = trPaid.getAttribute('_paid');
            document.getElementById('newfield').value = value;
            document.getElementById('form1').submit();
            return false;
        }
    </script>
    
    <form action='your controller' id='form1' method='POST'  
            onsubmit='javascript:updateHiddenField();'>
        ...
    </form>
    

    Then _paid’s value will be passed with request in newfield parameter


    And here’s how you get the parameter when you are using Spring MVC

    @Controller
    @RequestMapping("/blah")
    public class MyController {
    
        @RequestMapping(value="/morepath" method = RequestMethod.POST)
        public ModelAndView test(@RequestParam("newfield") int paid) {
            logger.debug("here's the value of paid: " + paid);
        }
     ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a programmer, new to jsp, trying to write some code. i have
I have some code within struts.xml like: <action name=viewApplicationPDF class=com.xxx.abc.web.action.XApplicationPDFAction> <result name=success>/WEB-INF/templates/xApplication.jsp</result> </action> I
I have written some code in JSP to download .docx files which is hosted
i am new in JSP,i have some problem with the following code : <%@
I have some JSP code, which writes a tree representing hierachical data. This data
I'm a c# developer but have a job that involves some jsp code. I've
I have a very simple issue. Below is my JSP code , where I
In the code below (jsf page), i have some hotel info in display:table rows
I have some old jsp code that uses the struts tags inside attributes, like
I have some code on two systems running kernel 2.4.20 and kernel 2.4.38 .

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.