Search Posts

Category: java

Angularjs & Java Servlet: How do i retrieve object being pass from angular service to java servlet

Hi guys i am integrating an angularjs and java for the first time but i do have wide experience in angularjs. my question is how do i retrieve object being pass to a java servlet. i pass the data using angularjs service function validateUser(){ var defer = $q.defer(); $http.POST(‘api/user’, data) .then(function(response) { defer.resolve(response); }).catch(function(response) { defer.reject(response); }) return defer.promise; } and my java servlet API: @WebServlet(“/api/user”) public class UserController extends HttpServlet { private static final […]

Angular 4 & Spring Security

I have two seperate server which is port 4200 for angular and port 8080 for backend using Spring. Angular for frontend and Spring as backend. I already succesfful in making Spring Security but seem i have fail combine with angular.. How to make spring security send to angular to redirect to login page if username and password were wrong. Its seem angular send parameter to spring because i can see at the console spring if […]

Jhipster pagination count issue

I am having issues with pagination in jhipster, the X-Total-Count is not correct, Everytime total-count gets returned is as same as the size that I send to the api, I even tried logging the page.getTotalCount and it also returns the same value as size that I send from frontend, I am not sure what happened to the project, cause everything was working properly before, I am using jhipster 4.1, mongodb is my database and angular […]

Spring Boot + Angular2 App – How to show index.html for specified routes?

I have developed a Spring Boot application that has @RestController for web api resources. I’m serving the front-end Angular2 website from the same Spring Boot application. Some of the url routes are in the Angular2 app. For example, currently when the url http://localhost:8080/myapp is typed in the browser, it shows the index.html page from Angular2 app. Within this page there’s more routing. Eg: http://localhost:8080/myapp/route1 http://localhost:8080/myapp/route2 These are working fine as long as I go to […]

Spring Boot shows the String instead of the HTML file from an Angular2 Single Page app

I’m trying to map all GET requests to unmapped url of the site to show the index.html file. So, I created the following @RestController: @RequestMapping(method=RequestMethod.GET) public String redirectToIndex() { return “index.html”; } My index.html is in resources/static/index.html. I also tried the following controller: @RequestMapping(method=RequestMethod.GET) public String redirectToIndex() { return “/static/index.html”; } However, in both cases, browser literally shows the strings index.html and /static/index.html respectively instead of showing the html file. I tried a lot of […]

Null pointer exception while trying to upload a CSV file to the server

I am trying to upload a csv file to the server. Below is my code in html: <form method=”post” id=”uploadCSV” enctype=”multipart/form-data”> File to upload: <input type=”file” id=”uploadfile” name=”file” accept=”text/csv”> <input type=”submit” value=”Upload” id=”uploadcsv” ng-click=”uploadCSV()”> Press here to upload the file! </form> And my JS:- $scope.uploadCSV = function() { var fileToLoad = document.getElementById(“uploadfile”).files[0]; var csvreporturl = “/api/oel/csv”; $http.post(csvreporturl, fileToLoad).then(function(response, status) { console.log(“posted:”,response); }); } Finally the controller in Spring Boot:- @RequestMapping(value = “/api/oel/csv”, method = RequestMethod.POST) […]

Centralized session in multiple product having different domain

I am developing centralized admin module for multiple product. Trying to maintain same session across multiple product. For Product1 : Authenticate successfully and send token in response header Request URL:http://localhost:8080/admin-web/rest/authenticate/ Request Headers Accept:application/json, text/plain, */* Accept-Encoding:gzip, deflate Accept-Language:en-US,en;q=0.8 Cache-Control:no-cache Connection:keep-alive Host:localhost:8080 Origin:http://product1.com:9090 Pragma:no-cache Referer:http://product1.com:9090/p1/ User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.109 Safari/537.36 Response Headers Set-Cookie:token=asdf123sfs1f23sfsf321sfsf21; Version=1; Comment=””; Domain=localhost; Path=/ Access-Control-Allow-Credentials:true Access-Control-Allow-Origin:http://product1.com:9090 Content-Encoding:gzip Content-Type:application/json Date:Mon, 13 Nov 2017 12:38:27 GMT Server:Apache-Coyote/1.1 Transfer-Encoding:chunked Vary:Origin Vary:Accept-Encoding […]

how can I use mitreId openid in a angular and java based project

I am fairly new to the openId connect, I want integrate MitreId OpenId connect server in my project that is based on angular and java (servlet), but I have no idea how to integrate. I read the documentation of mitreId but unable to configure it. Please help me with some example or link so that I can understand and able to implement. Requirement When I try to login with app it go to the mitreid […]

Angularjs $http spring rest controller – 404 error

I am getting 404 error on making a $http call from angularjs to spring controller, here is the code : Factory : factory.checkCodeAvail = function(url){ return $http({ url: url, responseType:”json”, method: “GET”, headers: { “Content-Type”: “application/json” } }); } This factory method is called by controller : commonFactory.checkCodeAvail(‘findDepartment’) .then(function (success){ console.log(success); },function (error){ console.log(error); }); This is the error i m getting in browser console : GET http://localhost:8080/TexERP/findDepartment 404 () Spring controller : @RestController public […]

Next Page »