• 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

action forward problem : when "Failure"

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When an error is found in validate and the forwarded to failure mapping I find that redirection does not occur. I have specified redirect="true" in struts-config.
Because of this, the layout is in disorder since I use css, which is a big problem. I know the css problem may be solved if i use absolute url of the css resource. But,i cant do that for several reasons. and even if i can do it somehow, i am still curious why this problem occurs in the first place. Should it not redirect to the page when redirect attribute is true?

 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's one sure-fire way to tell whether a redirect occurred or not. Check the URL. If it ends with xxxForm.jsp, then a redirect did occur. If it ends with xxxPost.do, then it didn't.

If you're having problems with the JSP finding th .css file, I'd suggest using the <html:base/> tag. This tag makes it so that all references in the page are relative to the location of the current JSP page.
[ August 07, 2006: Message edited by: Merrill Higginson ]
 
azhar bharat
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it ends with xxPost.do, so its not a redirect.

Any idea why redirect does not happen?
[ August 07, 2006: Message edited by: azhar bharat ]
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have a global forward with the name "Failure"?
 
azhar bharat
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes, ofcourse.
see the code in the first post.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code in your first post shows me a local forward. I'm asking if you have a global forward of the same name, particularly one that does not redirect.

A global forward looks like this:

<global-forwards>
<forward name="foo" path="/foo.jsp"/>
</global-forwards>
[ August 08, 2006: Message edited by: Merrill Higginson ]
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the css issue? Here is the code I have in my JSP files for loading the css file.

<link rel="stylesheet" type="text/css" href="<html:rewrite page='/css/style.css'/>" />

And about the redirect problem...Am I misunderstanding something? When validation fails the input attribute is used, not your Failure forward. Why would you want to redirect on the validation failure case?

- Brent
 
azhar bharat
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, i missed the "global" in your post.

I do not have any global forwards for "failure".

for sake of clarity, i am posting my global-forwards
 
azhar bharat
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I have not sorted out this problem yet.
Can anyone help?
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried. When validation fails the path specified by the input attribute is used, not your "Failure" forward (unless I missed some changes in Struts 1.2). I am still not sure why you would want to redirect on a validation failure.

- Brent
 
azhar bharat
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got confused a bit.

Here is the problem again.

when i use the "failure" mapping to redirect from Action, it works fine, it redirects and the page is proper.

But when there is an error in ActionForm the control is NOT REDIRECTED, ONLY TRANSFERRED to the page in the "input" attribute. So, i can see the page, but the address bar shows xxPost.do which is the Action mapping, which means that it is not redirected.

How do i redirect to the page instead or a forward when an error occurs in the ActionForm?
[ August 23, 2006: Message edited by: azhar bharat ]
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was looking into this a little more. The documentation and source that I looked at was for Struts 1.1, so you might want to double check your version of Struts. The controller element in your struts-config file has an attribute named inputForward. The default value is false. It looks like if you set this value to true, then Struts (the code in RequestProcessor) will treat the value in the input as the name of a forward. This may work for you, though I am pretty sure you would have to apply this change to all of your action mappings.

Add this entry to your struts-config file:


Change your mapping to something like this (I just changed the input attribute):


- Brent
 
azhar bharat
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Brent Sterling:
I was looking into this a little more. The documentation and source that I looked at was for Struts 1.1, so you might want to double check your version of Struts. The controller element in your struts-config file has an attribute named inputForward. The default value is false. It looks like if you set this value to true, then Struts (the code in RequestProcessor) will treat the value in the input as the name of a forward. This may work for you, though I am pretty sure you would have to apply this change to all of your action mappings.

Add this entry to your struts-config file:


Change your mapping to something like this (I just changed the input attribute):


- Brent



thanks, it redirects now.
reply
    Bookmark Topic Watch Topic
  • New Topic