Hi, I am using struts with WSAD for creating my web application. I have a jsp page which intern calls a css file and displays images also. when I call my jsp: , test1.jsp, the page displays fine and I can see the i,ages and the css file also takes effect.
Now, I added an action mapping, updateAction in my struts config file
</action-mappings> Here, when I added the action mapping, I am forwarding to the same page, test1.jsp after a success. ie, my form is getting submitted and I am coming to the same page.
But when the same page gets displayed again, the images are not getting displayed and its not recognising the css file. My console gives the following errors:
[3/19/04 9:16:40:408 CST] 154a763c OSEListenerDi E PLGN0021E: Servlet Request Processor Exception: Virtual Host/WebGroup Not Found : The web group /images/logo.gif has not been defined
Why is this happening ?
Do I need to add anything so that the images and css files are recognised from an action link ?
Joined: Sep 25, 2003
I think that your problem is occurring because you wrote your jsp page to be able to find your images and css file relative to the url that the jsp is accessed from. However, when a request is forwarded from an action, the url does not change to indicate a move to the jsp page. Try using the <html:base/> tag to fix this. Just insert this tag in the head section of your html. This tag will make it so that the jsp page tries to find the images and css relative to the same location, regardless or the url.
In addition to the <html:base/> tag, make sure that you reference your images/css using a neutral location, meaning: <LINK rel="stylesheet" type="text/css" href="<html:rewrite page='/theme/Master.css'/>"> Using html:rewrite instead of hardcoding the location of the css/images.
Joined: Jul 31, 2001
Thank you for the quick responses. Yes, My directory structure is like this testweb javasource webcontent css jsp images js And this is how I refer to a css file <link rel="stylesheet" type="text/css" href="../css/mine.css" /> using <html:base/> tag helped. Thanks again
Originally posted by Shreya Menon: And this is how I refer to a css file <link rel="stylesheet" type="text/css" href="../css/mine.css" /> using <html:base/> tag helped.
----- If you're sure your structure will never change, then that's fine. If not, you'd be wise to follow Brad's advice about using html:rewrite with the css href. Using a relative path is just inviting trouble to come back and bite you in the future. With rewrite, you are at least sure what the path is relative to. Just my humble $0.02 though.
Hi, I am using context path in my JSPs to refer to the images and css files as follows <link rel="StyleSheet" type="text/css" href="<%=request.getContextPath()%>/cssStyle/menu.css"> try this way it will pick up the files and images when the page is getting loaded or reloaded