I'm trying to implement search method
in my project and I want to pass the query from the HTML
page to the search servlet
, I tried so many ways but when I print the value passed to the search servlet
I get null
,I don't know what is wrong:Is it the way I pass the value from HTML
? Or Is it the way I read the value in the Servlet
?
Here's what I tried last:
Page.html
:
<div class="modal-body">
<div class="form-group">
<input ng-model="searchinput" placeholder="search channels, users " ng-change="search()" />
</div>
</div>
In the Controller
that contains the modal:
$scope.search = function() {
$http.get("http://localhost:8080/ExampleServletv3/SearchServlet",$scope.searchinput)
.success(function(response) {
$scope.records = response;
$scope.result = $scope.records;//this variable will hold the search results
});
};
SearchServlet.java
:
BufferedReader reader = request.getReader();
String query=reader.readLine();
System.out.println(query);
I tried also getParameter("searchinput")
but nothing worked.
Can somebody help me please?
Thanks