• 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

Is stylesheet not visible to Struts

 
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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">

<html>
<head>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ page
language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"
%>

<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="IBM WebSphere Studio">
<META http-equiv="Content-Style-Type" content="text/css">
<LINK href="../theme/Master.css" rel="stylesheet" type="text/css">

<title><template:get name='title'/></title>
</head>

<body>
<p>
<template:get name='header'/>
<template:get name='content'/>
<template:get name='footer'/>
</body>
</html>
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
PradeepPillai Pradeep
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great! It started working after putting the <html:base /> tag.
 
PradeepPillai Pradeep
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually either of this tricks works.
Thank you.
 
It will give me the powers of the gods. Not bad for a tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic