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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:58:50+00:00 2026-05-23T06:58:50+00:00

I am unable to redirect to another page using struts2 when i manually submit

  • 0

I am unable to redirect to another page using struts2 when i manually submit the form and not by form’s action

my struts.xml part

<action name="login" class="com.abc.csm.actions.Login">
         <result type="plainText" name="success"></result>
    </action>
<action name="home">
        <result name="success" type="redirect">/view/Welcome.jsp</result>
    </action>

on index.html i have a form with 2 fields, email and project id so i submit this form like

$(function() {
    $("#loginSubmitBtn").click(submitLogin);

    function submitLogin()
    {
        if(validate())
        {
            $.post("/csm/login.action",
              { emailaddress:   document.getElementById("email_id").value,
                projectid:      document.getElementById("project_id").value },
                  function(xml)
                  {
                        if($(xml).find('isSuccess').text()=="true")
                        {
                            sessiontoken=$(xml).find('sessiontoken').text();
                            $.post("/csm/home.action", {
                                sessiontoken:    sessiontoken
                            });
                        }
                  }
            );
}
    }
});

});

In the above code i am trying to get sessiontoken from server side response, validate if login was a success and then redirect it to /csm/home.action, but i does not gets redirected, I am using fiddler to monitor, and i can see the content of Welcome.jsp (/csm/home.action is mapped to Welcome.jsp in struts.xml) in response, but no redirection happens. What is the solution here? Thanks

Updated this works, Also can you check the way I am attaching sessiontoken is it correct?

  $('#submitDBtn').click(function(event){
    event.preventDefault();
    if(validate())
    {

        $.post("/csm/login.action",
          { emailaddress:   document.getElementById("email_id").value,
            projectid:      document.getElementById("project_id").value },
              function(xml)
              {
                    if($(xml).find('isSuccess').text()=="true")
                    {
                        sessiontoken=$(xml).find('sessiontoken').text();
                        /*$.post("/csm/home.action", {
                            sessiontoken:    sessiontoken
                        });*/
                        $('#launch').attr('action', '/csm/home.action?sessiontoken='+sessiontoken);
                        $('#launch').submit();
                    }
              }
        );

    }

});
  • 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-23T06:58:51+00:00Added an answer on May 23, 2026 at 6:58 am

    try doing this

    upon success instead of

    $.post("/csm/home.action", {sessiontoken:sessiontoken});
    

    try

    window.location = "/csm/home.action"+sessiontoken;
    

    abt form submit

    have a look here

    http://jquery-howto.blogspot.com/2009/05/disable-submit-button-on-form-submit.html

    you can disable the default behaviour of form with javascript and then after some processing submit the form using jquery

    http://api.jquery.com/submit/

    and about whether its a good way or not it depends but i have hear and read that one should avoid it …

    EDIT
    about sending sessiontoken in hidden field, just before submitting the form do this

    var hiddenField = document.createElement("input");
        hiddenField.setAttribute("type", "hidden");
        hiddenField.setAttribute("name", "sessiontoken");
        hiddenField.setAttribute("value", sessiontoken);
        var form = document.getElementById("yourFormId");
        form.appendChild(hiddenField);
        $('#formid').submit();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I am trying to redirect a page when certain condition is not page
How can I redirect the user to the same poll page instead of the
I am unable to do the following thing: In a page I have a
I have made an app as a Page Tab. I need to redirect to
I need the html returned using render_to_response to be escaped. I am unable to
I have an action which I need to post forward onto another action if
If I use the following setting, I am unable to use Server.Transfer()/Response.Redirect() to redirect
I have a link in the html page and it has the id=redirect and
I asked the same question Redirect to site if WWW part is missing but
I'm unable to change a culture of .aspx page. When I specify the culture

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.