Earlier on today I used Python (via Flask, some HTML and my Raspberry Pi) to help turn my Amazon Kindle into an eInk digital clock. This was cool and I was happy until I decided I wanted to do the same thing via Java and TomCat.
For this project I am using:
- A Raspberry Pi 3 as my web server
- Apache Tom Cat to serve the JSP file
- A Java JSP file
- A very basic CSS file to control the font size
- An Amazon Kindle
A .jsp file is a Java Server Page file and contains static material (e.g. text / HTML) and dynamic content (in this case the time). The <%@ tag is used to describe what the file contains and any Java libraries that need importing. The <% tag is where dynamic content is used. As with my earlier Python/Flask version I am using a CSS file to control style and a http refresh command to force the page to refresh.
More information on JSP files can be read at https://en.wikipedia.org/wiki/JavaServer_Pages
The time.jsp contains the following:
<%@ page language=”java” contentType=”text/html”%>
<%@ page import=”java.text.*,java.util.*” %>
<link rel=”stylesheet” type=”text/css” media=”screen” href=”main.css”>
<meta http-equiv=”refresh” content=”30″>
<% SimpleDateFormat sdf=new SimpleDateFormat(“HH:mm”); %>
<h1><%= sdf.format(new Date())%></h1>
The main.css contains the following:
Both the time.jsp file and the main.css file are stored in the /webapps/ROOT/ folder of my TomCat set up. For my set up this location was at:
As with the Python version there is some inaccuracy as the page auto refreshes every 30 seconds, this can be edited to a small refresh but this will mean the eInk screen is used more.