javascript - Request dispatching from one JSP to another JSP -
I am currently working on a payment gateway type project. If there is a verification error in the back end, first I want to show an error message on my JSP page (payment gateway) and after 10seconds, I send the object (error code) to my JSP merchant (webpage of the merchant) Want page
Currently, when I try to send and forward in my JSP page, my error message / content is not shown in jsp. Instead of showing my error messages, it is just waiting for 10 seconds and the object moves the merchant forward. Because I hope that I am not allowing permission / response to my JSP in sending a dispatch. Correct me if I'm wrong.
Please suggest me a good way to handle this situation?
I am trying to do this in my JSP page ..
& lt; / Head & gt; & Lt; Body & gt; & Lt; form: form method = "post" commandName = "item" & gt; & Lt; Form: Errors Path = "*" cssClass = "errorblock" element = "div" /> & Lt; TR & gt; & Lt; Td> Response code: & lt; / Td> & Lt; Td> $ {Item.responseCode} & lt; / Td> & Lt;% = "Test"% & gt; & Lt; / TR & gt; & lt;% Thread Sleep (10000); // sleep 10 seconds request dispatcher rd = request.getRequestDispatcher ("/ merchant.jsp"); //rd.include (request, feedback); Rd.forward (request, response); & Gt%; & Lt; / Body & gt; You can not output output to Jsp and Then go to the thread or something else, the webserver does not send the output until the code is executed, because we are not able to see your code, I think you are trying to output error, thread Go, and then send a redirect, whatever it will have to write it and then immediately send it to the client, redirection Send a message.
Your best bet would probably be to use Javascript to send a redirect to the page on which you are redirecting customers to display the error.
Edit: Since the comment formatting is odd: the servlet was not going to wait 10 seconds and was to send the redirect again, because all the processing responses are done before sending, the fact After that the only way to send more data would be Javascript, or any other weird black magic, the simplest and most elegant solution would be: & lt; Script ty pay = "text / javascript" & gt; window.location.replace ("http://yourwebsite.com/merchant.jsp"); & Lt; / Script & gt;
Comments
Post a Comment