Hacker News new | ask | show | jobs
by data37 3587 days ago
Here is what I settled with for my website after trying a few things over the years. In the process I have discarded nodejs, JAX-RS, maven, Undertow, JQuery, bootstrap (partially) etc.

Currently, pure java servlets serve json over REST-like API. The jar dependencies are servlet-api.jar, a couple of json-related jars and an sqlite jar. Multiple fine-grained sqlite files for data. Tomcat as the servlet container with no static content.

A nodejs reverse proxy forks the API and static web requests between tomcat and another nodejs static webserver. The static content is angualrjs + html + css with minimal and reusable js files mostly fetching json data. I also have a little bootstrap dependency for forms.

I have an apache ant build file that copies the ~60kb war file and static content directly to the production from my dev system. Tried maven before but Ant seemed much simpler and more than enough for my needs. The ant build does a lot other things also.

I use Eclipse for the easy navigability across the code and other nice refactoring features. Ant does all the build work.

Earlier I tried pure nodejs (no java), then JAX-RS and then Undertow container etc. Nothing seemed simpler than the current setup. By the way, the site is https://worktheme.com

3 comments

> A nodejs reverse proxy forks the API and static web requests between tomcat and another nodejs static webserver.

Just curious why you don't use nginx here. It will serve static files and proxy to the API. I'm sure the nodejs proxy was easy enough, but adding in gzipping files, rewrite rules, SSL, etc and it seems like nginx would even end up being more simple.

NodeJS rev proxy allows custom logic after intercepting requests - all in javascript. Not sure if NGinx would allow that. But yes, I would probably move to Nginx in near future for its tomcat-like robustness.
Your system of minimal dependency java is interesting. Do you have anything open source I can look at or otherwise get a dive into this technique?
Sure - Will publish to github and post here. For a brief note, the java servlets use Google's gson for interfacing wih web requests. Beyond that it is all plain old JDBC with sqlite. That is all to the "API" part of our service :-)
Come on, Java is a very rare language of choice for web development since I can't think of a popular website written in Java :|
It depends on what you mean by a "website". You need to understand that a web application need to have a client-side (managing user interaction) and a server-side (mostly fetching data). Java is still more popular than any other technology for the server-side part. May be you should read more. And think more.
I meant the back-end. Noone bothers to write the front-end with these languages ( ASP.Net is an exception ) when there are tons of great JS libraries avalable.