I have a login page login.jsp. User validation is done at server side. data is sent using the $http post request. My doubt is on successful login i want to redirect the user to home page. How do i do this..? Do i need to use the RequestDispatcher in servlet or $window.location in Java script. How angular will handle this issues. Angular js is used to develop Single Page Applications. Can anyone clearly explain this with an example.
3 Answers 3
You can inject $location
into your controller that handles the login, and use $location.url('/home')
as seen here. It would look something like this:
myApp.controller('LoginController', function($location) {
// whatever code to process login and store user info
$location.url('/home');
})
I hope that helps!
Comments
In your JSP code, on successful login, use the
response.setHeader("Location", site);
Useful resource is http://www.tutorialspoint.com/jsp/jsp_page_redirect.htm
Comments
in your angular controller you can use
$location.path( "yourpath" );
and dont forget to add
$scope.apply()
after location path
http://localhost:8080/Angular/login.jsp
. 2nd page url needs to behttp://localhost:8080/Angular/home.jsp
. But when i redirect the url is like 'localhost:8080/Angular/test.jsp#/Home.jsp`