Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an optional controller for serving static assets #315

Open
erdlet opened this issue Jun 24, 2022 · 3 comments
Open

Provide an optional controller for serving static assets #315

erdlet opened this issue Jun 24, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@erdlet
Copy link
Member

erdlet commented Jun 24, 2022

Problem

At the moment it is not possible to use a more complex Jakarta REST application, used by an Jakarta MVC application, on the context root. The main problem is that any static resources, like e. g. src/main/webapp/static/css/style.css, would be served by the Servlet container starting from the context root of the application, which is already handled by the Jakarta REST application. As a result, a HTTP response with status 404 is sent.

Idea

To avoid this situation and enable Jakarta MVC applications to be deployed on the context root, Krazo could provide an optional StaticAssetController which serves the necessary files. In a first step, the served files could be set up in a fixed directory structure, e. g. WEB-INF/static/[css,js,...] and served by this new Controller. The MIME types of the files are handled by the type mapping provided by the Servlet Container or the application's web.xml.

PoC

I'll add a PoC within the next days as a basis for discussion.

Would be happy to get some feedback from @eclipse-ee4j/ee4j-krazo-committers :)

@erdlet erdlet added the enhancement New feature or request label Jun 24, 2022
@erdlet erdlet self-assigned this Jun 27, 2022
@erdlet
Copy link
Member Author

erdlet commented Jul 19, 2022

I just had a few minutes to upload the PoC: https://github.com/erdlet/poc-krazo-asset-controller

I think a resource like this can be really helpful for "Jakarta MVC only" applications to get static assets provided by the MVC implementation. This way we could also provide helper methods via MvcContext so CSS may be accessed by ${mvc.css}/foobar.css.

@erdlet erdlet added this to the Future milestone Jul 28, 2022
@erdlet erdlet modified the milestones: Future, 3.1.0 Aug 10, 2022
@erdlet
Copy link
Member Author

erdlet commented Aug 30, 2022

After testing this a little bit I found a few topics that need investigation:

  • How to solve subdirectories? At the moment, the PoC can't handle paths like /js/foobar/somescript.js
  • GlassFish seems to have a different resolving mechanism for WEB-INF/ files than e. g. WildFly. Maybe there is a better place for the static resources than WEB-INF/.

@erdlet
Copy link
Member Author

erdlet commented Dec 2, 2022

GlassFish seems to have a different resolving mechanism for WEB-INF/ files than

This bug was fixed by GlassFish, so we can add this feature now and it should behave identical in all application server we support at the moment.

@erdlet erdlet removed this from the 3.1.0 milestone Mar 17, 2023
@erdlet erdlet removed their assignment Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant