Back to the Main Page
All these can be found in the archive file (Source Archive) including the ByteArrayBuilder.
ByteArrayBuilder is used quite a bit through out these classes.
I've added the code I use to extract parameters from the post/get actions, including multi part posts.
Files committed get added to the UPLOADS_DIR folder and the properties will include a FIELD_NAME_FileName property.
The abstract class would look something like this:
The HELLO WORLD handler is simply:
A static file handler would look something like this:
The control thread looks something like this:
The main class looks something like this:
For HTTPS servers see How to Get A Certificate From Let's Encypt.
The configurator would look something like this:
Linux only allows root to open port 80 and 443, so I've used
this library
to reduce the privilege to a fix user (in this case uid and gid = 1000).
Need these four classes:
The main class : SetUID.java
The group class : Group.java
The password class : Passwd.java
The rlimit class : RLimit.java
This is my script that allows you to register a service for serviced (the comments are required).
I first put the script into /etc/init.d/
I then ran sudo update-rc.d webd enable
And finally sudo systemctl enable webd
Any changes to the /etc/init.d/webd script you will need to run sudo systemctl enable webd again.
#!/bin/bash
### BEGIN INIT INFO
# Provides: webd
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Starts the website
### END INIT INFO
start() {
cd /usr/local/web/
java -jar MyWeb.jar &
}
stop() {
touch /usr/local/web/exitplease
}
help() {
cd /usr/local/web/
java -jar MyWeb.jar -?
}
if [ "$USER" != "root" ]
then
echo "Web server can only be stopped/started by root."
exit 2
fi
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 10
start
;;
?)
help
;;
*)
echo "Usage /etc/init.d/webd {start|stop|restart|?}"
;;
esac
I have created this page so I can keep track of how I did things.
Back to the Main Page
Viewed times.