Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

CSS Stylesheet Reference

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm new to using XSLT/XML to deliver web pages to a user. However, I have managed to create a working servlet example using the response Printwriter to return the results to be displayed. But I am unable to link the CSS stylesheet referenced in a <link> attribute in the XSLT page. The page displays but with no style information. The (existing) folder structure (not designed by me) looks like this:

Existing JSPs are contained under the web folder, CSS stylesheets under css, and servlets under classes.

What is the correct way to reference a stylesheet in the css folder from the output of a servlet (in the classes folder)? I have been considering creating a generic JSP in the web folder and dumping all servlet output into it but it seems like there must be a better way. Besides, I hate to create a JSP just for that purpose.

Thanks for your assistance!
[ September 10, 2005: Message edited by: James Danson ]
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi James,

Welcome to JavaRanch!

Just remember that the URL is used by the browser to fetch the stylesheet, and the browser knows nothing about anything in WEB-INF. If the stylesheet URL is a relative one, it's relative to the apparent URL of the JSP or servlet it's embedded in; if it's absolute, then it's the URL you'd need to type in the browser to fetch that file.

So if your web app is named "web", as I'll assume it is from the above, then the absolute URL would be "http://server/web/css/stylesheet.css"; if the JSP appears at "http://server/web/foo.jsp", then the proper relative URL is "css/stylesheet.css".
 
James Danson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ernest. I've got it working now.
 
I just had the craziest dream. This tiny ad was in it.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic