• Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable to import external resources on JSP  RSS feed

 
Ilya Zhavoronkov
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello! I  have multi-modules MAVEN project and I can't import css, bootstrap or any other external resource on JSP in my webapp-layer. I added this:


JARs located in my project's resources dir c:\project\localrepo\

JSPs are here C:\project\webapp\src\main\webapp\WEB-INF\jsp

These examples dint' work for me.


I can import css only with jstl:


But with jstl I can't import maven's bootstrap css/js libs....

Any suggestions?
 
Rob Spoor
Sheriff
Posts: 21095
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anything in WEB-INF is not available to the outside world, only to your own Java/JSP code. Can you show us the internal structure of the WAR, especially where these CSS files etc are located?
 
Rob Spoor
Sheriff
Posts: 21095
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I've created my own little test application, and tested it with WildFly 10.1.0, and the following works for me:

That will work out of the box only for servlet 3.0 compliant servers. Otherwise you will need to read this: https://www.webjars.org/documentation#servlet2
 
Ilya Zhavoronkov
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:Anything in WEB-INF is not available to the outside world, only to your own Java/JSP code. Can you show us the internal structure of the WAR, especially where these CSS files etc are located?


This is my WAR.



I think I just figured out how to fix that. But I still think there's more elegant way.
 
Ilya Zhavoronkov
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:OK, I've created my own little test application, and tested it with WildFly 10.1.0, and the following works for me:

That will work out of the box only for servlet 3.0 compliant servers. Otherwise you will need to read this: https://www.webjars.org/documentation#servlet2


doesn't work for Tomcat for some reason..
 
Rob Spoor
Sheriff
Posts: 21095
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ilya Zhavoronkov wrote:I think I just figured out how to fix that. But I still think there's more elegant way.

Move your css folder outside of WEB-INF and put it directly in your src/main/webapp folder. That way, it will be put in the root of your WAR, which makes it publicly available.

Ilya Zhavoronkov wrote:
Rob Spoor wrote:OK, I've created my own little test application, and tested it with WildFly 10.1.0, and the following works for me:

That will work out of the box only for servlet 3.0 compliant servers. Otherwise you will need to read this: https://www.webjars.org/documentation#servlet2


doesn't work for Tomcat for some reason..

Have you tried the servlet 2 solution? If not, can you share your Tomcat version?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!