• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unable to import external resources on JSP

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic