aspose file tools*
The moose likes Struts and the fly likes Struts 1.1 forward mapping problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 1.1 forward mapping problem" Watch "Struts 1.1 forward mapping problem" New topic
Author

Struts 1.1 forward mapping problem

Billy Blanks
Greenhorn

Joined: Apr 13, 2011
Posts: 11
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.

Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Jordan,
Post the java script part to find out what went wrong


Have Fun with Java
little,little.. little by little makes a lot..
Billy Blanks
Greenhorn

Joined: Apr 13, 2011
Posts: 11
Shankar,
Thank you for the reply. Here you are (Sorry about the formatting):
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

where are you redirecting? can you provide the code for that
Billy Blanks
Greenhorn

Joined: Apr 13, 2011
Posts: 11
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

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

Joined: Apr 13, 2011
Posts: 11
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

Joined: Jan 30, 2011
Posts: 329

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

Joined: Apr 13, 2011
Posts: 11
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

Joined: Apr 13, 2011
Posts: 11
Maybe it is worth mentioning that I am using Struts 1.1 as well.
Billy Blanks
Greenhorn

Joined: Apr 13, 2011
Posts: 11
Is there anyone out there that can help me on this issue?
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

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

Joined: Apr 13, 2011
Posts: 11
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

Joined: Apr 13, 2011
Posts: 11
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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts 1.1 forward mapping problem
 
Similar Threads
regarding c:redirect and jsp:forward
Problem while redirecting to action class from AJAX
struts Action for asynchronous HTTP processing
Page not refreshed using Struts actions
Ajax to show a table with Display tag