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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:06:35+00:00 2026-06-03T04:06:35+00:00

I have a JSP Page which I am using to redirect to another url

  • 0

I have a JSP Page which I am using to redirect to another url (cross domain), so using jQuery I placed a button click event under which response.sendRedirect should trigger, but as soon as the page loads it redirects it does not even wait for alert. What is the problem here? Please help.

on body load it calls load()

<script language="JavaScript">
    function load(){
        <%
        String message=(String)request.getAttribute("error");
        if(message != null){
            out.println("alert(\"" + message + "\");");
        }
        %>

    }

    /*a range of options (products) based on which it decides redirection or form submission
    * will lead to the new webapp*/
    var productArray=["iirDefault","ilmDefault","mdmDefault"];
    $(document).ready(function(){       

    });

    /*Button event handler for the intermediate screen for product selection after login*/
    $('#btnLaunchCSM').click(function(event){
        event.preventDefault();

        var selectedProduct=$('input[name=product_name]:checked').val();
        if(jQuery.inArray(selectedProduct, productArray)!=-1)
        {
            e_add=$("#emailaddress").val();
            p_id=$('input[name=project_id]:checked').val();
            alert(e_add+", "+p_id);
            <% 
            String e_add=request.getParameter("email_id");
            String p_id=request.getParameter("project_id");
            response.sendRedirect("http://abhishek:9090/abc/view/loginProxy.jsp?email_id="+e_add+"&project_id="+p_id); 
            %>


        }
        else
        {
            $("#launchSSO").submit();
        }

    });
</script>
  • 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-03T04:06:36+00:00Added an answer on June 3, 2026 at 4:06 am

    You seem to expect that JSP scriptlet and JavaScript runs in sync as you have coded it. This is not true. Java/JSP runs in webserver and produces HTML. HTML/JS runs in webbrowser. Rightclick page in browser and View Source. If Java/JSP has done its job right, you should not see any single line of it in the generated HTML/JS output.

    You need to send a (ajax) HTTP request to your server instead. You can use jQuery for this or just a plain form submit. Or you can just perform the redirect fully in JS. Replace that smelly <% %> block by:

    window.location = "http://abhishek:9090/abc/view/loginProxy.jsp?email_id="+e_add+"&project_id="+p_id; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Struts1.3, I have Jsp page which is showing the list of
I have a popup using div and javascript in a jsp page which also
I have a jsp page which I'm using to display a datatable. If I
I have a jsp page which should load a popup using ajax. The content
I have a JSP page which accepts SQL queries, performs them then returns the
I have a jsp page which needs a java code. This java code inside
I have a JSP page, which accepts user strings in more than 23 languages.
Hi I have a page in my java/jsp based web application which shows list
I'm using Spring Web Flow (v. 1.0.5) and I have a JSP page that
I have a functional JSP page that accepts URL parameters and updates a table

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.