Kodvel
Simple MVC structure for java Servlet and JSP
Install / Use
/learn @Rezve/KodvelREADME
Kodvel
The aim of this project is to provide a simple MVC structure to organize your Servlet applications.
Features:
- Controllers support multiple methods to handle multiple requests.Like
Postclass can haveindexmethod for showing all post,viewfor viewing a single post,editfor edit post form,storefor saving post by POST request. - Easy route for binding URL patterns to Controller and method.
Getting Started
Prerequisites
- JDK 8
- NetBeans IDE 8.2 or leter
Installing
- Clone the project into your machine or download as a zip.
git clone https://github.com/rezve/kodvel.git cd kodvel - Open the project with NetBeans IDE
- Run the project. A welcome page will open in your default browser.
Project Structure
├── Web Pages
│ ├── WEB-INF
│ │ ├── views # define your views in this folder (JSP files)
│ │ └── web.xml
│ └── resources # static resources (css,js,image, etc)
│
├── Source Packages
│ ├── app
│ │ ├── config # project configuration
│ │ ├── controllers # all the controller classes
│ │ ├── models # all models (Beans)
│ │ └── routes # register your routes here
│ └── Kodvel # system files
└── ...
Quick start
Step 1:
Let's start by creating a simple JSP view in view/blog folder
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Blog</title>
</head>
<body>
<h1>List of Posts</h1>
</body>
</html>
Setp 2:
Now, Create a controller class inside app/controllers folder. This will serve our views.
public class Blog extends Controller{
public void index(HttpServletRequest req, HttpServletResponse res) {
req.setAttribute("posts", posts);
view("blog/posts", req, res);
}
public void create(HttpServletRequest req, HttpServletResponse res) {
view("blog/create", req, res);
}
...
}
NOTE: All methods (those are used for handling user request) inside a controller must have this two argument.
We have completed our first controller. Now register it to receive user request.
Step 3: Define a route in app/routes/web.java
public void registerRouter() {
...
Router.get("/blog", new Blog(), "index");
Router.get("/blog/create", new Blog(), "create");
}
here we registered our index method for handling all the request for /blog and create method for /blog/create url.
Done! Lets visit http://localhost:8080/kodvel/blog
You will see your views in the browser.
List of Posts
So here is the flow:
- Create your views (JSP) with html/css design and data passed from the controller.
- Create a model for holding data.
- Create a controller to fetch data from DB and process other logic and pass the data to view.
Documentation
- Application life cycle
- Controller
- Routing
- View
- Model
- Static assets
- Form Validation
- Database
- Configuration
- Filter
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
TODO LSIT
- Utility function for base URL
- Form validation
- Database support
- Simple database helper method
- Completing this Documentation.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
- Md. Rezve Hasan - Initial work - github
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Acknowledgments
- Name and routing style of this project inspired by laravel
Related Skills
node-connect
350.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
