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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:24:21+00:00 2026-05-18T11:24:21+00:00

Im trying some ajax call with Struts2 and the JQuery library. This is the

  • 0

Im trying some ajax call with Struts2 and the JQuery library. This is the code of the jsp :

<s:div id="my_result" >
    Nothing
</s:div>

<s:form action="UserManager" theme="simple">
    <s:textfield name="nickname" />
    <s:password name="password" />
    <s:label cssClass="menu_span">
        <sj:submit targets="my_result" value="Login" />
    </s:label>
</s:form>

this is the code of the bean/action with the xml :

public class UserManager extends ActionSupport {
    private String nickname;
    private String password;

    @Override
    public String execute() throws Exception {
        String output="i have insered "+this.getNickname()+" and "+this.getPassword();
        System.out.println(output);
        return output;
    }

    public String getNickname() { return nickname; }
    public void setNickname(String newValue) { nickname=newValue; }

    public String getPassword() { return password; }
    public void setPassword(String newValue) { password=newValue; }
}

<package name="model" extends="struts-default">
    <action name="UserManager" class="model.UserManager">
        <result>index.jsp</result>
    </action>
</package>

If i return SUCCESS on the UserManager bean, it load on my_result the same calling page. Else, if i return output i get Messages:
No result defined for action model.UserManager and result i have insered aaa and bbb
messagge (with nickname=aaa and password=bbb).

What’s happened? How can i return that string? I think it’s a struts.xml fault

Cheers

UPDATE

public class UserManager extends ActionSupport {
private String nickname;
private String password;
private String error;

@Override
public String execute() throws Exception {
    error="i have insered "+this.getNickname()+" and "+this.getPassword();
    return SUCCESS;
}

public String getNickname() { return nickname; }
public void setNickname(String newValue) { nickname=newValue; }

public String getPassword() { return password; }
public void setPassword(String newValue) { password=newValue; }

public String getError() { return error; }
public void setError(String newValue) { error=newValue; }
}

<s:div id="my_result" >
    <s:property value="error" />
</s:div>

<s:form action="UserManager" theme="simple">
    <s:textfield name="nickname" />
    <s:password name="password" />
    <s:label cssClass="menu_span">
        <sj:submit targets="my_result" value="Login" />
    </s:label>
</s:form>

UPDATE 2

<package name="model" extends="json-default">
    <action name="UserManager" class="model.UserManager">
        <result type="json" />
    </action>
</package>
  • 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-18T11:24:21+00:00Added an answer on May 18, 2026 at 11:24 am

    The return value that you return in the execute() method must be one of the mapped as values.
    As you have not a result name like this:

    <result name="resultName"></result>
    

    It will use the default one: “success”. You have to return “success” value in execute() method.

    The result value of the execute method is the name of the result mapped. To send a message you have to add a String attribute in your Action (and a getter to obtain it), and in the execute method do something like

     this.message = "my message";
    

    Edit: how to get the message with ajax:
    If you have set the message in your action in an attribute called “String message” and you have a getter for that attribute (public String getMessage()) you can get this information accesing this property in the object you get in the ajax call. If you do the ajax call for example with jquery you can get it in this way:

    $.ajax({
        url: '/yourAjaxUrl',
        success: function(data) {
           var message = data.message;
           alert('The message is '+message);
           $('#my_result').html(message);
        }
    });
    

    Edit:
    In the struts xml in your package tag you have to define the json type:

    <result-types>
        <result-type name="json" class="com.googlecode.jsonplugin.JSONResult">
        ...
    </result-types>
    

    and add the json-plugin.jar which can be downloaded here

    more info in http://code.google.com/p/jsonplugin/wiki/Documentation

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

Sidebar

Related Questions

Trying to create and submit form within a javascript call. This code works fine
I'm having some issues with a jQuery AJAX call. My code works fine when
I'm trying to generate some XML for a jQuery.get (AJAX) call, and I'm getting
I am trying to post some data with jQuery Ajax, but the parameters in
Looking for some help on my AJAX/jQuery implementation. I am trying to load some
I'm trying to validate a form using an AJAX call to check available inventory.
I'm trying to get the success data from a jquery Ajax call so I
I had a previous question can jquery ajax call external webservice? and some good
I am trying to perform an ajax call inside a form (a Drupal node
I am trying to make an ajax call by passing named parameters: $this->Js->link('Save',array( 'controller'

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.