I am developing an application using jquery along with servlets. I am using jquery theme roller for the interface. In my Login.jsp
<html>
<head>
<script>
$(document).ready(function() {
$("#dialog").dialog();
});
</script>
<script>
$("#submit").click(function(){
$("#LoginForm").submit(function()
{
var username=$("#username").val();
var password=$("#password").val();
var datastring='username='+username+ '&password= '+password;
$.ajax({
type: "POST",
url:'Login',
data: datastring
error: function(){
alert("Data Error");
},
success: function (data){
window.location.replace("Items.jsp");
}
});
});
});
</script>
</head>
<body style="font-size:62.5%;">
<div id="dialog" title="Login">
<form id="LoginForm" method="post">
<fieldset>
<label>Username:</label>
<input type="text" id="username"></input><br></br>
<label>Password:</label>
<input type="password" id="pwd"></input><br></br>
<input type="submit" id="submit" value="Log In" align="middle"></input>
</fieldset>
</form>
</div>
The data is passed to the servlet, and as soon as the login is successful, I want the user to be redirected to a new page, for example, Items.jsp. In my callback, I used window.location.replace ("Items.jsp") . I can not redirect.
I tried using response.sendRedirect ("Items.jsp") and return * "Items.jsp" *
But I can not redirect it to a new page. Where am I mistaken.
Thank:)
bumblebee
source
share