M S Reddy
M S Reddy

Reputation: 196

Calling JSP file from JavaScript

I am calling a Servlet from index.jsp using Ajax. If the result is false, I have to display an error message on index.jsp itself. But, if the result is true, how do I call another JSP page?

Upvotes: 1

Views: 1030

Answers (1)

BalusC
BalusC

Reputation: 1108642

In JavaScript, you can use window.location to change the current location.

E.g.

if (result.error) {
    document.getElementById('message').innerHTML = result.error;
} else {
    window.location = 'another.jsp';
}

Upvotes: 1

Related Questions