• 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

Not JSP. Anyone know how to just use .html files

 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So basically I have a Java Web Application built on top of Servlets and JSP spec. However, I am not using .jsp files. I have just straight .html pages as all the dynamic content will come from ajax calls and json.

I have been able to display my index.html page, but none of the css styling is happening even though I see the links to the stylesheets in the view source. The pathing should work.

Anyone know if they have to be .jsp pages to get those links to the stylesheets to work

WEB-INF
--index.html
--css/style.css

and on my html page

<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.4.1/build/cssreset/cssreset-min.css">
<link href="css/style.css" rel="stylesheet">


The rest is irrelevant.

Thanks

Mark
 
Saloon Keeper
Posts: 7590
177
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you used a tool like LiveHTTPHeaders or Firebug to ascertain that the CSS files are being accessed OK (meaning, the requests result in 200 or 304 responses) ?
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chrome and Safari have excellent built-in network tools to see what files are being loaded, and even how long they take, and in what order.

I always advise against using page-relative addressing in web apps. It's fragile and easily broken. Better to use server-relative addressing that starts with the context path. Because they are static HTML files, that means you'd have to hard-code the context path. Ick.

Me, I'd like convert them to JSPs just so I could grab the context path dynamically.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Chrome and Safari have excellent built-in network tools to see what files are being loaded, and even how long they take, and in what order.

I always advise against using page-relative addressing in web apps. It's fragile and easily broken. Better to use server-relative addressing that starts with the context path. Because they are static HTML files, that means you'd have to hard-code the context path. Ick.

Me, I'd like convert them to JSPs just so I could grab the context path dynamically.



Thanks. I think going to jsp might be what I do. I mean I can use jstl and do some looping and stuff, which I wouldn't get through straight html.

Do you have an example of the jsp line for using server-relative addressing, so if my css files are in my war files WEB-INF/css directory?

THanks

Mark
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
CSS files can't be under WEB-INF. The container cannot serve anything out of WEB-INF or its sub-folders. Resources such as style sheets, images and script files must not be under WEB-INF.

If the css files were under, say resources/styles, a typical URL would be:
 
Sheriff
Posts: 22784
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

Bear Bibeault wrote:CSS files can't be under WEB-INF. The container cannot serve anything out of WEB-INF or its sub-folders.


It can, but it would need a servlet and URL mapping for this content. For the resources you mention it's not worth it though. The only reason to put them in WEB-INF is to hide them from the "outside world", and by creating a servlet and URL mapping you would be unhiding them. Then what's the point of hiding them in the first place?

So I agree, don't put these resources in WEB-INF.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys, I don't know why I always thought that all those files were in the WEB-INF directory in all the projects I have done at companies, but looking back at those projects, I see that they are indeed outside of the WEB-INF directory.

Now for server related paths, is jsp the only way to get the context path easily, or can it be done in straight html pages?

Thanks

Mark
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no way to get the context path programmatically without JSP or some other server-side assist.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic