J2EE-WS-Jersey is a practical Java EE project that demonstrates how to build RESTful web services using the Jersey framework (JAX-RS reference implementation). This project covers REST API endpoint creation, MVC integration with JSP, multipart file uploads, dependency injection, and middleware patterns using request and response filters. It’s perfect for developers looking to learn modern REST API development and middleware integration in enterprise Java applications.
J2EE-WS-Jersey/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── lk.jlat.app.jersey/
│ │ │ ├── annotation/
│ │ │ │ └── UserBind
│ │ │ ├── config/
│ │ │ │ ├── AppConfig
│ │ │ │ └── DependencyBinder
│ │ │ ├── controller/
│ │ │ │ └── HomeController
│ │ │ ├── middleware/
│ │ │ │ ├── RequestFilter
│ │ │ │ └── ResponseFilter
│ │ │ └── model/
│ │ │ └── User
│ │ ├── resources/
│ │ └── webapp/
│ │ ├── upload/
│ │ └── WEB-INF/
│ │ ├── views/
│ │ │ └── index.jsp
│ │ └── web.xml
│ └── test/
├── pom.xml
-
UserBind
Custom annotation for name binding, enabling targeted middleware or dependency injection for user-related resources.
-
AppConfig
Jersey application configuration class. Registers controller and middleware packages, enables JSP MVC integration, and sets the template base path. -
DependencyBinder
Configures dependency injection for theUsermodel using HK2.
-
HomeController
Handles root REST endpoints and file uploads.GET /renders the JSP view with a dynamic model.POST /file_uploadsupports multipart file uploads and saves files to the server.
-
RequestFilter
Logs or preprocesses all incoming REST requests. -
ResponseFilter
(Can be enabled) Handles logging or modification of outgoing REST responses.
-
User
Request-scoped POJO representing user data, supporting dependency injection and annotation-based binding.
-
index.jsp
JSP view rendered by Jersey’s MVC feature, displaying dynamic content from the controller.
- web.xml
Configures Jersey’s servlet filter, application class, and URL mapping for REST endpoints.
- ✅ RESTful API endpoints built with Jersey (JAX-RS)
- ✅ MVC integration with JSP for dynamic web views
- ✅ Multipart file upload support
- ✅ Dependency injection with HK2 and custom binding
- ✅ Middleware logic using request and response filters
- ✅ Clean, modular Maven project structure
-
Jersey Configuration:
AppConfigsets up the Jersey application, registers controllers and middleware, and enables JSP support for MVC-style views. -
REST Controller:
HomeControllerhandles HTTP GET requests for the home page and POST requests for file uploads, saving files to the/uploaddirectory. -
Dependency Injection:
DependencyBinderensures theUsermodel can be injected where needed. -
Middleware Filters:
RequestFilterlogs or processes incoming requests;ResponseFilter(optional) can log or modify outgoing responses. -
JSP View:
index.jspdisplays dynamic content from the model, demonstrating REST-to-view integration.
- Java 11
- Jakarta EE 10 (JAX-RS)
- Jersey (MVC, Filters, Multipart)
- JSP
- Maven
- Commons IO
- ✅ Build RESTful web services with Jersey in Java EE
- ✅ Integrate MVC patterns with REST endpoints and JSP views
- ✅ Implement multipart file uploads in REST APIs
- ✅ Use dependency injection and annotation-based binding
- ✅ Apply middleware logic with request and response filters
- ✅ Structure enterprise Java projects for clarity and maintainability
Chamika Gayashan
Undergraduate Software Engineer | Sri Lanka
Linkedin: @chamikathereal
Current date: Tuesday, June 24, 2025, 8:46 PM +0530
