Click here to Skip to main content
15,311,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to get string from java method using AJAX request($http GET) and then to show it in my html using AngularJS, but I can't access my java function to retrieve information from it. It gives me 404 not found error every time. If someone can give me some example of how to do it or change my code to work it would be really helpful.

My html:
<pre><!DOCTYPE html>

<script src="js/angular.js"></script>
<script src="js/angular-route.js"></script>
<script type="text/javascript" src="js/Proba.js"></script>


<body ng-app="app" ng-controller="kontroler">

	<h1>Probavam po stoti put ovo sranje!!!</h1>



My Angluar:
var app = angular.module("app",[]);

	$scope.hello = "Hello World!";
	$scope.helloFunction = function(){
			url: 'rest/servisi/ime',
			method: 'GET'
			$scope.bilokako =;

My java function:

package Servisi;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

public class Name {
	public String Naziv() {
		return "Hello World from Function !!!"; 

<pre><?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="" xmlns="" xsi:schemaLocation="" id="WebApp_ID" version="3.0">
		<servlet-name>Jersey REST Service</servlet-name>
		<servlet-name>Jersey REST Service</servlet-name>
		<!-- Bazna putanja do REST servisa. Može biti bilo šta (pa i prazan string) -->

What I have tried:

I give you my example in which I tried to access my information from java method, but I can't retrieve it with REST in AJAX request.
sajeetharan 22-Jul-18 9:08am
are you getting the data in the console?
Member 13810592 22-Jul-18 9:25am
Nope, i dont have anything in console...
Member 13810592 22-Jul-18 9:27am
sajeetharan 22-Jul-18 9:45am
screenshot was removed
Member 13810592 22-Jul-18 9:50am
hmm i have it let`s try here :
Member 13810592 22-Jul-18 9:55am this is when i try to access field bilokako...
sajeetharan 22-Jul-18 15:14pm
thats not how you access data. tell me what do you see when you put console.log(JSON.stringify($scope.bilokako));
Member 13810592 22-Jul-18 16:51pm
sajeetharan 23-Jul-18 0:38am
please contact me via email
Member 13810592 23-Jul-18 14:18pm
I send you a message.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900