So, This is my view
<div>
<div class="loginDiv">
<form name="loginForm" ng-submit="validateDetails()" novalidate>
<div class="userNameDiv">
<label class="label" for="username">User Name:</label>
<input type="text" id="username" name="userName" class="input-medium" ng-model="employee.userName" required ng-minlength=5 ng-maximumlength=20/>
</div>
<div class="passwordDiv">
<label class="label" for="password">Password:</label>
<input type="password" id="password" name="password" class="input-medium" ng-model="employee.password" required />
</div>
<button type="submit" class="btn-large">SUBMIT</button>
</form>
</div>
</div>
and the controller to the view is
angular.module('employeeApp.controllers')
.controller('LoginPageController',['$scope','authenticationDataModelService',function($scope,authenticationDataModelService)
{
$scope.validateDetails=function(){
employee={};
employee.userName=$scope.employee.userName;
employee.password=$scope.employee.password;
console.log(employee);
authenticationDataModelService.validateData(employee);
}
}
]);
I am sending this employee object to the service file in which i am sending it in a post request(not including the entire service code):
$http.post(this.employeeDataUrl,employee);
and I am sending it to server and the servlet code is
public class LoginService extends HttpServlet{
public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
PrintWriter printWriter=response.getWriter();
response.setContentType("text/html");
String userName = request.getParameter("userName");
String password = request.getParameter("password");
EmployeeDAO employee = new EmployeeDAO();
System.out.println(userName+""+password);
boolean validateLogin=employee.validateLogin(userName, password);
if(validateLogin){
printWriter.println("Login Success");
}
else{
printWriter.println("Login Failed");
}
}
}
but i am getting null values here. I am unable to send the values in the employee object from service file in angularjs to the servlet.How could i achieve this??Pardon me if the question is silly...