• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Unable to import external resources on JSP

 
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?
 
Sheriff
Posts: 21805
104
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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: 21805
104
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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: 21805
104
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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?
 
Any sufficiently advanced technology will be used as a cat toy. And this tiny ad contains a very small cat:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!