• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

JSP configured in web.xml

 
Ranch Hand
Posts: 300
Eclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have a jsp at location c:\tomcat5.5\webapps\Myplots\src\jsp\Welcome.jsp Welcome.jsp

[code]

<link rel="STYLESHEET" type="text/css" href="../css/PlotManagement.css">

</STYLE>
</HEAD>
<%
response.setHeader("Cache-Control","no-store"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at
%>

<div ID=maindiv>

<%@ include file="header.jsp" %>


and my PlotManagement.css is at c:\Tomcat5.5\webapps\Myplots\src\css\PlotManagement.css

i configured the jsp in web.xml as


<servlet>
<servlet-name>second</servlet-name>
<jsp-file>/src/jsp/Welcome.jsp</jsp-file>
</servlet>

<servlet-mapping>
<servlet-name>second</servlet-name>
<url-pattern>/welcomepage</url-pattern>
</servlet-mapping>

The raw data present in my jsp is given as output with out formatting it which is done by including the .css files... my jsp do not includes the css files but when i remove the configuration from the web.xml it shows output by including the .css file i tried by modifying the path of the included file but it still does not show me the formatted output produced using .css file...
please help me with this..
 
Sheriff
Posts: 67642
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your resource URLs are likely malformed. Please see the JSP FAQ on resource URLs for more information.
[ October 05, 2008: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the problem is with the relative URL for the CSS reference.

This should be an absolute URL, and possibly relative to the context path.
So without using JSP-EL,



The reason is when you invoke the jsp from /src/jsp/Welcome.jsp the path ../css does work,

but when it is invoked as /second/, the ../css would be looking up at the sibling level of the context path to the application.

Additionally, if you have not ran into problems with the setting of headers for cache control yet, typically setting response headers needs to be done before any content would be sent back to the client. So in your example, moving the the response.setHeader.. stuff to be the very first line in your JSP file, before you render HTML, HEAD, might help that from breaking later too.
 
Bear Bibeault
Sheriff
Posts: 67642
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Travis Hein:
This should be an absolute URL...

If by "absolute URL" you mean one beginnning with http:// (what absolute is usually taken to mean), then no.

The URLs should be context-relative (not absolute) as described in the FAQ entry I mentioned and as you showed in your example.
[ October 05, 2008: Message edited by: Bear Bibeault ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic