Two Laptop Bag*
The moose likes Java in General and the fly likes Style Sheet Problem in Websphere Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Style Sheet Problem in Websphere" Watch "Style Sheet Problem in Websphere" New topic
Author

Style Sheet Problem in Websphere

Chris Morrell
Greenhorn

Joined: Aug 10, 2005
Posts: 11
Hello. If anyone here has any experience with Websphere or iSeries, I would appreciate some help. I posted this topic in the Websphere forum , but it seems that forum isn't very active. Anyway, I can't get my style sheet to work with a java servlet application that I installed on an iSeries server. I put together the app and style sheet through WebSphere and exported everything to the server as an .ear file, installed the application and the program works; however, the app isn't accessing the style sheet. I'm new to both iSeries and Websphere. I've been trying this line:
writer.println("<LINK rel='stylesheet' type='text/css' href='Master.css'>");
and have tried putting the style sheet in the same folder as the class file, tried putting it in the Java Source folder, tried it all over the place really and have tried making the path absolute. I've also tried pasting the .java file into the classes folder with the .class file. None of my efforts have been successful. Is this even possible? Any help would be appreciated. Thank you.
Choon-Chern Lim
Ranch Hand

Joined: Aug 29, 2005
Posts: 74
No.. don't put css file in WEB-INF (where your java classes are), because this folder is not accessible in your presentation file (jsp etc...).

Create a CSS folder under your project WebContent and drop this css file there.

To reference it, do something like this:-

Chris Morrell
Greenhorn

Joined: Aug 10, 2005
Posts: 11
Thanks a lot for responding.
You showed me this code in your response:
<LINK rel='stylesheet' type='text/css' href='/mycontext/css/Master.css'>
Sorry, but I'm not sure I get the "mycontext" reference. Does that mean my "WebContent" folder? Or is the "mycontext" the path from the class file to the css folder? Please bare with me. Thanks.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

You don't need to make a css folder, nor do you need to use "mycontext". The important part is just to put the CSS file someplace that a browser can request it. That means in the area where JSP and static content files would go -- i.e., at the top level of the web application directory -- the directory that is the parent of WEB-INF.

You certainly can make a "css" directory if you want, and name this directory in the LINK tag. Not a bad idea for a complex web app.


[Jess in Action][AskingGoodQuestions]
Chris Morrell
Greenhorn

Joined: Aug 10, 2005
Posts: 11
Thanks for your response.
Still not having any luck. Let me update you on my directory setup now. When my project is exported, my .class file is in project.ear\project.war\WEB-INF\classes. My .css file is in project.ear\project.war\css. My .java file does not get exported at all. Here is the line I have right now linking to the style sheet:
writer.println("<LINK rel='stylesheet' type='text/css' href='..\\..\\css\\Master.css'>");
Now this would appear to make sense to me, but it ain't working. Any ideas?
Thanks for helping.
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
What about

writer.println("<LINK rel='stylesheet' type='text/css' href='css/Master.css'>");


SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
Chris Morrell
Greenhorn

Joined: Aug 10, 2005
Posts: 11
Thanks for responding. I'll try that out next, although I think I tried that yesterday. I'm going to print out the directory listing in my browser and see if I can figure out just where my .class file thinks it is.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Yes, what David said.

I see where your brain is at, though. You're thinking that the path is going to be interpreted by the Servlet class, but it's not! The Servlet is just spitting out text which, coincidentally, happens to be HTML and happens to include the name of a file. But the Java code in the Servlet doesn't "know" that, right? You're just printing text.

Later, that HTML ends up in a Web browser, which says "OK, this HTML document specifies a stylesheet, I better ask the web server for it. The path will be interpreted by the Web server as a relative path from the webapp's base URL; the Web server, at this point, hasn't the faintest idea that the HTML was generated by some class down in WEB-INF/whatever.
Chris Morrell
Greenhorn

Joined: Aug 10, 2005
Posts: 11
Son-of-a-gun! The thing's working! Thanks to you all. I bow down before you.
 
Consider Paul's rocket mass heater.
 
subject: Style Sheet Problem in Websphere
 
Similar Threads
Run Ant in WSAD to adminster Websphere server
tomcat on iseries
SSL and certificates Configuration in WebSphere Application Server 7
Tomcat on iSeries
WSAD 5.1ejbdeploy with JRE version 1.4