aspose file tools*
The moose likes Servlets and the fly likes Problems with Servlets + CSS + forward Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problems with Servlets + CSS + forward" Watch "Problems with Servlets + CSS + forward" New topic
Author

Problems with Servlets + CSS + forward

Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
Hi fellows..
I have a bunch of jsp pages with a cascading style sheet. If I do forward from a servlet to the JSP the CSS doesn't work, but if I do a response.sendRedirect the jsp 'recognizes' the CSS.
As far as i know, forward is faster because it does not create a new request, so I was using it for this reason. In some cases I'm using redirect because it displays in the status bar in which page the user is currently located.
Has anyone experienced this problem? I'm using Forte for java 4.0 CE bundle with Tomcat.
thanks


I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12779
    
    5
Remember that with a forward, the browser still thinks it is talking to the servlet URL so that is the base it uses to try to locate additional resources such as images or CSS files. The solution is to either use an absolute URL for your CSS reference or (my favorite) include a BASE tag in the HEAD area of your HTML page to provide the browser with the correct URL.
Bill
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
Thank you William

The solution is to include a BASE tag in the HEAD area of your HTML page to provide the browser with the correct URL.

sorry 4 asking this dumb question, but what is the URL i should use?
my web application is in my c drive under:

i tried <base href="http://localhost:8081/"> and <base href="\\"> with no luck
thanks
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12779
    
    5
The URL has to point to a directory that the web server can serve pages from. If I understand your layout right, try
href="/myCSS"
Generally I think the best way to figure this sort of thing out is to make a plain HTML page prototype. Once you get that working you can convert to a servlet or JSP.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problems with Servlets + CSS + forward