6

How fitting because that just happened today: MOTHERF*CKING Tomcat.

TL;DR:
Tomcat sucks with client side routing (e.g. in angular2).

How hard can it be to provide a web/application server which is properly configurable?
I lost a whole day by trying to get an angular2 project deployed in Tomcat.
It's not that I could not manage to deploy it. But that you need to put all the files in the ROOT folder if Tomcat so that your JavaScript files can be found is the first dumb part.
But that's not enough.

There seems to be no way in Tomcat, short of writing to XML config files and including one jar library, to disable routing go a webapp. And you need to do this when you have a single page application with client side routing.

But yeah, dear boss, I get the part where Tomcat is lightweight, easy to use and does most of the work for you: when you do not use it.

As a side note, so that nobody thinks I have a grudge against the Apache guys: I see the advantages of a Tomcat if you have multiple webapplications written in Java which you need to manage our if you use it as an embedded application server.
But there are just some occasions where a plain old Apache Webserver is better suited.

Another side note: if I just embarrassed myself because those are settings which can be easily applied feel free to tell me 😉

Comments
  • 1
    @Artemix
    Not if you build a single page application. You just exchange content in the page depending on the current routing, but this is all done on client side with angular2, means a route change is not send to the server but just handled locally.
    So let's say your page is located at
    www.mypage.com/interface/index.html
    And your user clicks on a navigation link, e.g. "photos", then your path is actually "/photos" but in your browser it is shown as
    http:///www.mypage.com/interface/...
    If the user now would road the page manually this whole path is indeed send to the server. But in this case you just want it to deliver index.html again and don't care about the rest.

    API calls (REST) to load some data you want to display would be send to the server, but with a differently prefixed path, so e.g.
    www.mypage.com/API/...
    And this would not affect the routing of the page.

    Out of curiousity: why do you prefer websockets over simple Ajax calls?
  • 1
    I think I am going to deploy my progressive web app in Angular 2 in a few days, on tomcat.. I asked my boss if we could deploy it on firebase, the answer was "NO".
Add Comment