This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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 javaservlet 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.
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:-
Joined: Aug 10, 2005
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.
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.
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.
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.
author and iconoclast
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.
Joined: Aug 10, 2005
Son-of-a-gun! The thing's working! Thanks to you all. I bow down before you.