java - Login Validation Using Angular Js and JSP -
i making angular js - jsp application, have created login page, have created servlet fetching database , comparing username , password. created login form , passed values angular controller on login form submit. need access servlet compares login how pass information servlet ? have created factory that, have use post method passing datas.
i pasting code til have done.
html
<div class="container"> <form name="myform" novalidate class="col-md-4 col-md-offset-4"> <h2>{{login.username}}</h2> <div class="form-group"> <input type="email" ng-model="login.username" required class="form-control input-lg" placeholder="email"> </div> <div class="form-group"> <input type="password" required ng-model="login.password" class="form-control input-lg" placeholder="password"> </div> <div class="form-group"> <input type="submit" ng-disabled="myform.user.$dirty && myform.user.$invalid || myform.email.$dirty && myform.email.$invalid" ng-click="formsubmit(login)" class="btn btn-primary btn-lg btn-block" value="sign in"/> <span><a href="#">need help?</a></span> <span class="pull-right"><a href="#">new registration</a></span> </div> </form> </div>
controller.js
var appcontroller = angular.module('appcontroller', []); appcontroller.factory('accountgroup', ['$resource', 'data', function ($resource, data) { return $resource( { query: { isarray: true, method: 'post' } } ); }]); appcontroller.controller('logincontroller', ['$scope','$http', function ($scope,$http) { $scope.formsubmit = function(item) { debugger; console.log(item); }; }]);
this eclipse directory structure
loginvaldiator.java servlet used login comparison
to access servlet, add servlet mapping servlet in deployment descriptor file(web.xml).
eg :
<servlet> <servlet-name>servlet1</servlet-name> <servlet-class>org.mycompany.test1</servlet-class> </servlet> <servlet-mapping> <servlet-name>servlet1</servlet-name> <url-pattern>/path/test</url-pattern> </servlet-mapping>
here can access servelet .../path/test
Comments
Post a Comment