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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:53:05+00:00 2026-06-09T12:53:05+00:00

I know this is impossible to pass parameter from javascript to scriptlet code in

  • 0

I know this is impossible to pass parameter from javascript to scriptlet code in jsp page
So I want to use ajax to post my selected value to server and then get it in scriptlet code by request object
I use

<aui:select label="My Selection" name="ms" id="ms" onchange="<%= updateItem()%>" >
    <%
    for(String item : itemList){            
    %>
    <aui:option selected="<%= item.equals(selItem) %>" value="<%=item%>"><%=item%></aui:option>         
    <%}%>
</aui:select>

<%! 
private Object updateItem() throws Exception{
    //to do something with selected value
return null;
}%>

Please show me how to excute ajax post in this tag, or any tag can be used in my scenario

  • 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-09T12:53:07+00:00Added an answer on June 9, 2026 at 12:53 pm

    You don’t seem to realize at all how HTTP and web applications work. You have to learn about request/response cycle.

    The AJAX is the right thing to you for what you want to do, but as name says AJAX is Asynchronous JavaScript – and you try to put java method call in your onchange attribute. This won’t work.

    To do what you ask for first, you have to find your Portlet class, and implement serveResource(ResourceRequest req, ResourceResponse resp)
    method, where you will be receiving the selected value ( String selectedVal = req.getParameter("selectedVal") ) and returning something depending on that value.

    String result = null; 
    if ("blah".equals(selectedVal))
      { result = "Something"; } 
    else 
      { result = "Something Else"; } 
    resourceResponse.getPortletOutputStream().write(result.getBytes("UTF-8")); 
    

    Then you have to make your AJAX calls to that method. Should roughly look like this:

    <portlet:resourceUrl var="resourceUrl">
    <portlet:param name="selectedVal" value="PARAM_PLACEHOLDER_SELECTED_VAL" />
    </portlet:resourceUrl>
    <aui:script use="io">
    function ajax<portlet:namespace />MySelect(selectedVal) {
            A.io(
                '${resourceUrl}'.replace("PARAM_PLACEHOLDER_SELECTED_VAL", selectedVal),
                {
                    on: {
                        success: <portlet:namespace />processResponse(select, response);
                    }
                }
            );
    
    function <portlet:namespace />processResponse(response) {
    alert("Here's what java code returned:"+response+". Do whatever you want with it - with javascript");
    }
    </aui:script>
    
    ...
    
    <aui:select label="My Selection" name="ms" id="ms" onchange="ajax<portlet:namespace>MySelect(this.values[this.selectedIndex])" >
        <%
        for(String item : itemList){            
        %>
        <aui:option selected="<%= item.equals(selItem) %>" value="<%=item%>"><%=item%></aui:option>         
        <%}%>
    </aui:select>
    

    Hope this helps.

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

Sidebar

Related Questions

I would like to compile c# source code from a string. I know this
I don't even know how to explain this, so here is the code I'm
I use some javascript library for drawing charts. It need to pass arrays with
I'll try to be as specific as possible. I know this is impossible to
I was following this code for cucumber testing with activemerchant and authorize.net(I know it's
I know this may be impossible but... I just got an app approved, and
I know this is impossible, but how close can I get? I'm creating achievements,
This is my code: void get_pass(char *p); int main(){ char *host, *user, *pass; host
I know it's impossible to use return and yield return in the same method.
Know this might be rather basic, but I been trying to figure out how

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.