Skip to main content

Setting up a Tomcat server

This post covers the process of setting up Apache Tomcat 9 as a server for static .html pages.

Environment & Background

I have access to a VM running Ubuntu 18.04 on which I've already set up an instance of RStudio server. I have SSH access but not a graphical interface, so it's been a good opportunity to work on my Linux skills. My goal here was just to serve static HTML pages to site visitors for now. It's really satisfying to have full control over the HTML and CSS, instead of being in an environment like Wordpress (or Blogger!) where it's never quite clear what markup it will accept and what it will totally ignore. I've been mocking up a frontend for SOTU-db using W3-CSS, which feels like kind of a cross between traditional HTML/CSS/JS and React Native. 

I had played around with Ubuntu servers before, so I was familiar with Nginx and Tomcat. As I've said many times, my favorite part about Ubuntu is the documentation that is completely incomprehensible, and these two products are no exception. I think part of the problem is that both products can do a lot more than I need them for; Nginx seems popular as a reverse proxy (which I still may want to use in order to secure the web interface for SOTU-db) and Tomcat is like a... JavaScript app hosting... thing, or something. There's probably a simpler tool to do what I want, but I like the idea of learning to use tools that are actually used by pros and can leave room for expanding the project as time goes on. 

Installing Tomcat

Like I said, the Tomcat setup instructions make no sense. On the setup page of their documentation, after the Windows instructions, they have this helpful part:

Like, I hate these instructions. Why would you write "Source tarballs for jsvc are included with the Tomcat binaries" without even linking to the Tomcat binaries? I don't understand Linux devs' obsession with making instructions that are so obtuse. In the end, I used a tutorial from Digital Ocean (hm) which had the advantage of being very specific and doing some smart-sounding things like making a new "tomcat" user and group on the VM and creating a file to run Tomcat as a service, but the disadvantage of not really explaining precisely what was happening with each step or why.

I won't repeat all the steps here, but by changing a few xml files around and running some commands to change some permissions, I ended up with a file structure where I can just drop in HTML, CSS, and JS files and then load them up just by visiting a public URL. As I said before, it's fun to know that my changed in CSS will actually show up, instead of getting overridden by some content management system or whatever.

Building functionality

Now that I have this server, the next steps are to get it talking to the other pieces of the project. A super-basic and probably incorrect diagram of how I imagine these interactions happening is below. 

A nice thing is that the GET command for the search bar "form" was really easy to do and will automatically generate results like "" So, I'm fairly optimistic that I can somehow make RStudio or a go-between application or service listen for requests that end in "searchTerm=[whatever]", and use that as a trigger to pipe the [whatever] to, at the very least, a python script. I think getting the results back to the user will be more challenging - I suspect in order to hit deadlines it will end up just using "touch" to programatically generate a new HTML file that will get served back to the user. All this will probably take a few seconds, so I'll need to have a loading or busy indicator for the user. 

Next weekend I will be talking about SOTU-db as a "digital poster" at Loyola's History Graduate Student Association Conference so the pressure is on to create something that functions at at least a very basic level in the next week! 


Popular posts from this blog

Setting up an RStudio Server

I'm taking a break from React Native (our group decided not to use it for the Tic Tac Toe project) and wanted to put some thoughts in here about setting up my RStudio server for my SOTU-db project.

I won't get into the details of why I want the RStudio server here - that will be covered on the SOTU-db dev blog. Here, I just want to record some quick thoughts and problems that arose as I set up the server.  Gaining access to the server The server itself is a VM provided by Loyola University Chicago's Computer Science Department - thanks to George Thiruvathukal and Miao Ye for setting me up with this and providing support. 
I initially ran into issues because I couldn't figure out how to connect to the server. I knew I had been assigned a static IP and a DNS entry in Loyola's nameservers at, and assumed I would use SSH to connect to the server (which I further assumed was running Ubuntu in accordance with CS departmental policy and my previous expe…

New Position with Chicago Metro History Fair

I'm excited to have begun a new position at the Chicago History Museum a couple of weeks ago now. I am a "History Fair Program Specialist," meaning I help run the Chicago Metro History Fair.

The Chicago Metro History Fair (CMHF) is an annual, regional competition where middle and high school students in and around Chicago research a historical topic of their choice and create projects (exhibit boards, websites, documentaries...) that show off their hard work. Volunteer judges from around the community help provide feedback on the students' work, and winning entries can advance to state and national level competitions (administered by Illinois History Day and National History Day, respectively).

So far, my work has primarily been in preparing for weekend "Palooza" events, where volunteer coaches (often history teachers, faculty, graduate students, etc) and librarians assist students with their History Fair projects. The regional competition will take place i…