• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Stylesheet not loading using RequestDispatcher

 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am facing an unusual problem with my web application. It appears that if I forward control from my servlet to a JSP page, then it gets loaded properly with the form elements but the styleSheet doesn't get loaded. As a result, all the font types and colours go awry. Right now to forward to the JSP page I use the following command:


However, I've seen that if I use the following code snippet instead :

the JSP gets loaded properly alongwith the stylesheet.

But my choice of using the former code snippet is 'coz that's the right way to go about if one wants to set/get Attributes set in request object.

Is this problem due to the use of RequestDispatcher or for some other reason?

In the JSP page, the styleSheet is included using the following line within the <head></head> tags:


Are there some special <META> tags needed to be set incase of RequestDispatcher?

A little help.......
[ December 07, 2005: Message edited by: Anirvan Majumdar ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remember the brower is going to make a request for the stylesheet (or image or any other linked resource) in a place relative to the address where it thinks your page is. In this case the path in your url-pattern.

Either change the link so it's relative to the address showing in your browser's address window or (better) don't use relative links.
Make them all relative to the root of your app.

 
Anirvan Majumdar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a ton! It works fine
 
Ranch Hand
Posts: 245
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As suggested <%=request.getContextPath()%> instead of relative path,  does the trick for loading css, also possible for all kinds of img icons and so forth.

but see this: http://agrozoo.net/gallery/Erebiini
gets redirected in behind to:



why is this working with no problems (with relative css, ...)
and the other redirects to same page, with different stuff after '?' not (that is page loads, but no css, no images,...) ?
 
Miran Cvenkel
Ranch Hand
Posts: 245
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so if my link (which can be anything really, pointing to nowhere, in this case "foo", on page is like:



and in urlRewrite filter it gets redirected to:



It all works OK !

At this point if I change (basicaly adding extra /)
../foo/foo1
to
../foo/foo1/foo2
exact same redirection code, to exact same loc,  does not load css, ... anymore.

Any insight to that?

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic