• 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 1.1 forward mapping problem

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I am a newbie to Struts, JQuery and Ajax. The problem that I am having, is that I am trying to make an ajax call from a JSP to a struts action that makes a change to a database and upon "SUCCESS", have the control forwarded to another action that will redirect the user to another JSP and construct a page for the user. Everything seems to be working fine except the redirect part. The user is not redirected and only the HTML shows in the server response (using firebug). This is very confusing to me because the page that the user should get forwarded to never renders. But the html (with updated vaules) shows up in under the HTML section of firebug if the URL is expanded. Any help or comments on my issue would be greatly appreciated.

 
Ranch Hand
Posts: 329
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jordan,
Post the java script part to find out what went wrong
 
Billy Blanks
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shankar,
Thank you for the reply. Here you are (Sorry about the formatting):
 
Shankar Tanikella
Ranch Hand
Posts: 329
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
where are you redirecting? can you provide the code for that
 
Billy Blanks
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Shankar Tanikella
Ranch Hand
Posts: 329
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jordan,
I didnt use the combination of JQuery & AJAX to syntactically understand the ajax part provided. But what I can guess from the code & scenario is that, you are sending data to the server and getting it processed and then forwarding to some JSP in the same (used by ajax) action method itself (if that is true, then it is wrong) which renders the second/resultant JSP. This rendered JSP is sitting in the response text and the response text is shown in firebug. Though it is huge guess, it would be helpful to see the code snippets from action class as well.
How it should work out for you is as below


 
Billy Blanks
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So are you saying that I need to add another Ajax call inside of the first success:function(data) that calls the second action which redirects the user to the new page?
 
Shankar Tanikella
Ranch Hand
Posts: 329
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when we say "Submit form", it implies not through ajax (AJAX doesnt submit the form). it should be synchronous call to reload the page.

something like
 
Billy Blanks
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shankar,
To my understanding. I should be able to return ActionForwards from my action class that would allow me to transfer control to another action (the action that creates and displays the new jsp). The original action was requested via Ajax so that is why I believe that I should I have included some snipets from the action class that will hopefully shed some light on my issue.

 
Billy Blanks
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe it is worth mentioning that I am using Struts 1.1 as well.
 
Billy Blanks
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there anyone out there that can help me on this issue?
 
Shankar Tanikella
Ranch Hand
Posts: 329
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Biilly, when you call the first action using asynchronous call (AJAX), where is the response sent to the call made from JS? What you are trying here is sending asyn request and expecting sync response.. you need to receive the response for the 1st AZAX call and then submit the your second request (form)
 
Billy Blanks
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sankar,
To my understanding, the response should be received by the "data" parameter in the first Ajax call. See code below. It is also to my understanding, once the data is returned, further processing can be done on it. But my intent is not to even go into the second function because the of way the struts mapping are setup, the second JSP should be created before Ajax receives the return data. I was counting on the asynchronous nature of Ajax to achieve my result of having the page refreshed using struts mappings and tile definitions. Am I misunderstanding this? If my understanding is incorrect, please help me to understand.

 
Billy Blanks
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shankar,
When you say:

where is the response sent to the call made from JS?



I am a little confused. Isn't struts responsible for handling responses and forwarding them if needed via the action mappings?
 
Talk sense to a fool and he calls you foolish. -Euripides A foolish tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic