File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes JSP losing its style after an ActionForward Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "JSP losing its style after an ActionForward" Watch "JSP losing its style after an ActionForward" New topic
Author

JSP losing its style after an ActionForward

Andy Deighton
Ranch Hand

Joined: Apr 01, 2003
Posts: 39
Hi,
I have some pages in an /admin/ folder of my Struts-enabled site. One page has a link which executes an Action, which then forwards back to the same page. However, upon the forward (using mapping.findForward()), the page loses its style completely! I.e. the CSS that was once applied making it all nice and sexy, seems to no longer work and the page is all bland.
I'm sure I've seen this before but have no idea why?
Any clues?
Andy
UK
Eric Sexton
Ranch Hand

Joined: Sep 12, 2003
Posts: 133
Can you show us the part of the JSP that's losing it's style?
Andy Deighton
Ranch Hand

Joined: Apr 01, 2003
Posts: 39
Eric, I changed the ref to my stylesheet so it was absolute and it worked. I also suspect that if I'd used <html:base/>, then that would have helped too.
Regards,
Andy
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
This is quite a general point -- in Struts (& other MVC frameworks), the location of the JSP is the location where your view happens to sit. This does not necessarily have a lot to do with the request URL. In your JSPs, you should therefore avoid any relative path, because you cannot make assumptions about what you're going to be relative to. The Struts link and rewrite tags will help you here.
The only exceptions are static <@includes>. I'll leave the reason why as an exercise for the reader
- Peter
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP losing its style after an ActionForward