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.
My struts project uses a template. I also have a style sheet. I want the design in the style sheet to be in each jsp pages that are displayed to the user. Somehow it is not working now. Does anybody now why? I use WSAD for development. My template.jsp is given below:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
First of all, let's make one thing clear: This has absolutely nothing to do with Struts. A Struts JSP picks up a CSS just the same way any other JSP does.
One thing you have to realize about developing in WSAD:
The "base context path" used by the page desinger tool may not match the path for the page when it is being displayed on the server. Consequently, sometimes the page won't pick up the CSS in Page Designer, but it will on the server and visa versa.
There are a couple of options:
1- Put a <html:base /> tag at the beginning of your page. This indicates that all paths used on the page are relative to the JSP page itself.
2-Use a scriptlet to get the context path like this: <LINK href="<%=request.getContextPath()%>/theme/Master.css" rel="stylesheet" type="text/css"> The good news is this will cause the CSS to always be found on the server. The bad news is that it will never be found in WSAD Page Designer.