• 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

Struts help

 
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>

<action name="update" path="/update" scope="request"
type="com.test.testweb.actions.UpdateAction">

<forward name="success" path="/jsp/Test1.jsp">

</forward>

</action>

</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 ?

Thanks
 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Shreya Menon
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Poornima. Your approach works great.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic