中文文档 | English
A simple guestbook web application built with JSP/Servlet and SQLite database.
Deploy a live demo for free on these platforms:
- Railway.app - Easiest deployment, $5/month free credit
- Render.com - 750 hours/month free tier
- Fly.io - Generous free tier with persistent storage
- Google Cloud Run - 2M requests/month free
This project has been upgraded from a legacy IDE-based project to a modern, standalone web application:
- DevContainer Support - Zero-config cloud development with GitHub Codespaces and VS Code Remote Containers
- Maven Build Support - Added
pom.xmlfor dependency management and builds - Cross-platform Database Path - Fixed hardcoded Windows path to dynamic, cross-platform path
- Compilation Script - Standalone compilation without IDE
- Run Script - One-command application startup
- VS Code Integration - Pre-configured tasks and debug configurations
Use GitHub Codespaces or VS Code Remote Containers for zero-configuration development:
GitHub Codespaces:
- Click the "Code" button on the repository page
- Select "Codespaces" → "Create codespace"
- Wait for container to build (auto-compiles the project)
- Run
./run.shto start the application - Click the port forwarding notification to open in browser
VS Code Remote Containers:
- Install Docker Desktop and Remote Containers extension
- Open the project in VS Code
- Press
F1→ "Remote-Containers: Reopen in Container" - After container starts, run
./run.sh
For detailed instructions, see DevContainer Documentation
The simplest local method - script automatically downloads Jetty server and starts the application:
./run.shThen visit: http://localhost:8080/guestbook/
./compile.shOr using Maven:
mvn clean packageDeploy the web directory to any Servlet 3.0+ container (e.g., Tomcat, Jetty):
Using Tomcat:
# Copy web directory to Tomcat's webapps directory
cp -r web $TOMCAT_HOME/webapps/guestbook
# Start Tomcat
$TOMCAT_HOME/bin/catalina.sh runUsing Maven Jetty Plugin:
mvn jetty:runjspGuestbook/
├── src/ # Java source code
│ ├── control/ # Servlet controllers
│ ├── db/ # Database access layer
│ ├── model/ # Data models
│ └── Exception/ # Custom exceptions
├── web/ # Web resources
│ ├── WEB-INF/
│ │ ├── web.xml # Web application configuration
│ │ ├── classes/ # Compiled class files
│ │ └── lib/ # Dependency libraries
│ ├── css/ # Stylesheets
│ ├── js/ # JavaScript files
│ ├── fonts/ # Font files
│ └── *.jsp # JSP pages
├── lib/ # Project dependencies
├── test/ # Test code
├── pom.xml # Maven configuration
├── compile.sh # Compilation script
└── run.sh # Run script
- Java: 1.8+ (compatible with Java 21)
- Servlet API: 3.1
- JSP: 2.3
- Database: SQLite 3.x
- Build Tool: Maven 3.x
- Testing: JUnit 4.x
The application uses SQLite database with default path ~/guestbook.db (user home directory).
You can specify the database path using Java system property:
java -Ddb.path=/path/to/your/database.db -jar ...Or set it in the startup script:
export JAVA_OPTIONS="-Ddb.path=./data/guestbook.db"
./run.sh- User registration and login
- Post messages/notes
- View all messages
- Clean Bootstrap UI
- JDK 1.8 or higher
- Maven 3.x (optional)
- Servlet container (Tomcat 7+, Jetty 9+, etc.)
# Clean old compiled files
rm -rf web/WEB-INF/classes/*
# Recompile
./compile.shIf you encounter servlet-api not found error, the compilation script will download it automatically. If download fails, manually download:
wget https://repo1.maven.org/maven2/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar \
-O web/WEB-INF/lib/servlet-api.jarCheck database file path and permissions:
ls -la ~/guestbook.dbIf the database doesn't exist, the application will automatically create the table structure.
If port 8080 is occupied, you can modify the port configuration in run.sh, or start with a different port:
# Edit pom.xml to modify Jetty plugin port configuration
# Or specify port directly
mvn jetty:run -Djetty.http.port=9090This project is for educational and reference purposes only.
Issues and Pull Requests are welcome!