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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:05:15+00:00 2026-06-16T11:05:15+00:00

I’m running Glassfish web server with Strut2 and I would like to pull json

  • 0

I’m running Glassfish web server with Strut2 and I would like to pull json data from action class for a page without a page refresh. What I mean by that is that when a user changes a setting I would like to show updated data automatically without page refresh.

Making Ajax call to Strut2 action class seems to be my solution but all of my Google search resulted for the cases where page refresh is needed.

Action class:

...
@Override
public String execute() throws Exception {
    result = "\"{\"age\":100,\"name\":\"dude\"}"; 

    return SUCCESS;
}
...

strut.xml:

<package name="default" namespace="/" extends="json-default">
    <action name="getData" class="action.getData" method="execute">
        <result type="json" />
    </action>
</package>

ajax call:

jQuery.ajax(
{
    type: 'POST', 
    url: '/proj/getData', 
    data: {id: $('#id').val()},
    dataType: 'json',
    contentType: 'application/json; charset=utf-8',
    success: function(data){         
        alert(data.result);
    },
    error: function(XMLHttpRequest, textStatus, errorThrown){
        alert('Error ' + textStatus);
        alert(errorThrown);
        alert(XMLHttpRequest.responseText);
    }
}); 

Above code makes a correct call to correct function in the action class but two problems.

  1. I’m not sure how to pull the id data set in data section of ajax call in server side
  2. I get following error on server side on return.

    WARNING: StandardWrapperValve[default]: PWC1406: Servlet.service() for servlet default threw exception
      java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils
      at org.apache.struts2.json.SerializationParams.<init>(SerializationParams.java:57)
      at org.apache.struts2.json.JSONResult.writeToResponse(JSONResult.java:207)
      at org.apache.struts2.json.JSONResult.execute(JSONResult.java:171)
    

I’m very new to strut2 and I know I have done similar things with ajax and struts but I just can’t seem to figure this one out, so it would be appreciated if you can help.

  • 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-16T11:05:16+00:00Added an answer on June 16, 2026 at 11:05 am

    You need to add apache common lang package to your classpath, or WEB-INF/Lib. You can get it here
    http://commons.apache.org/lang/
    or add it as maven dependency if you are using maven.

    Second thing is you can access id as a parameter to url

    String id= request.getParameter("id"); to get request object the Action class must be implementing servletrequestaware .

    public class BaseAction extends ActionSupport implements ServletRequestAware {
    
    protected HttpServletRequest request = null;
    
    
    @Override
    public void setServletRequest(HttpServletRequest request) {
        this.request = request;
    }
    
    @Override
    public String execute() throws Exception {
       String id= request.getParameter("id");
       result = "\"{\"age\":100,\"name\":\"dude\"}"; 
    
       return SUCCESS;
    }
    
    }
    

    You can pass the id parameter as a GET request as well.

    jQuery.ajax(
            {
                type: 'GET', 
                url: '/proj/getData?id='+$('#id').val(), 
                //data: {id: $('#id').val()},
                dataType: 'json',
                contentType: 'application/json; charset=utf-8',
                success: function(data){         
                    alert(data.result);
    
                 },
                 error: function(XMLHttpRequest, textStatus, errorThrown){
                     alert('Error ' + textStatus);
                     alert(errorThrown);
                     alert(XMLHttpRequest.responseText);
                 }
            }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I am using jsonparser to parse data and images obtained from json response. When
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I would like to run a str_replace or preg_replace which looks for certain words
I am currently running into a problem where an element is coming back from
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to count the length of a string with PHP. The string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am confused How to use looping for Json response Array in another Array.

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.