Q:

Tomcat, Grunt build

I am using grunt for my angular js app, and tomcat for my server side.
Whenever needed, in dev env, I run Grunt build, takes dist folder and put it in tomcat webapp folder.
However, I have a weird issue. URLs within the app work only if I click on them from an HTML page.
e.g. if I type http://localhost:8080/upload - I will get 404 page not found error, however if from index page - http://localhost:8080 , I click on a link in page that leads to upload it works fine.
What could be the problem?
If I run the app on node.js, the links work perfectly! just on Tomcat it doesn't work as expected.
EDITED
I define the urls like this in angular js
angular.module('angularjsApp')
  .config(function ($stateProvider) {
    $stateProvider
      .state('upload', {
        url: '/upload',
        templateUrl: 'app/upload/upload.html',
        controller: 'UploadCtrl'
      });
  });

A:

The way you have angular setup its using history push state to navigate, changing the browser's URL without actually causing the browser to re-fetch its content from the back end.
So using push state the in the browser angular can navigate just fine, but when a request is actually sent to the server it responds 404 as you have nothing there to serve your HTML.
There are two solutions to this:

Switch to use #! urls so that from the server you're always getting the same URL (see other answers).
Update your server to serve the same static HTML for all paths (this answer). 

You need the servlet that's sending back your initial HTML content to do so for all routes - so mapped to /* rather than just / so any path it's given always returns the same HTML.
So your web.xml has a servlet that looks like this that's returning:
<servlet>
    <servlet-name>StaticHtmlServlet</servlet-name>
    <servlet-class>com.example.StaticHtmlServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>StaticHtmlServlet</servlet-name>
    <url-pattern>/</url-pattern>
    <url-pattern>/*</url-pattern> <!-- so this is what's added -->
</servlet-mapping>

