RE: Forwarding control
Mike, Your suggestion worked out perfectly! Thanks for the help. One other quick question, if you don't mind - since sendRedirect() doesn't send along the request object, is there another way to access it from the target url while still using this method? Thanks, James - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Forwarding control
James, Use response.sendRedirect() instead of the RequestDispatcher. That will change the URL in the browser. If you want to stick with the RequestDispatcher, you'll have to add some logic to catch a resubmission of the same data (possibly use a hidden field in your forms with a unique identifier, random number, timestamp, etc... and record those in the user session or a backend database) and skip over processing and go straight to the result.jsp. Hope that helps. Mike -Original Message- From: James Michelich [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 12, 2003 4:50 PM To: [EMAIL PROTECTED] Subject: Forwarding control Hello, any help would be much appreciated. The basic scenario is as follows - I have a form page called form.jsp (http://localhost/webapp/form.jsp). Upon submission, the form data is processed by a servlet mapped to the url '/process' (http://localhost/webapp/process). Once the servlet has completed processing the form data, it forwards control to a results page (http://localhost/webapp/result.jsp) via RequestDispatcher dispatch = request.getRequestDispatcher (forwardPath); dispatch.forward(request, response); My question is this - although control has been forwarded to the results page, the browser's url is still http://localhost/webapp/process, which is ok with me; however, if the page is refreshed, the browser prompts for the form data to be resubmitted and the processing is repeated (which for my application happens to be quite substantial), rather than refreshing the contents of the results page. I suppose this is a minor annoyance that could be worked around by displaying a link to the results page rather than forwarding directly to it, but I'd rather implement the latter. Does anyone know of a solution or workaround for this problem? Thanks in advance, James - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Forwarding control
The only way is to 'reconstruct' a new request object using a querystring So the url would need to be constructed with ?foo=bar&foo2=bar2 etc, etc. The thing with sendRedirect() is that it sends an HTTP code to the browser, which then makes a brand new request, so there is no way for the browser to know about the previous 'request' unless you fake it out with the querystring. If you have objects, you'll have to use a session. > -Original Message- > From: James Michelich [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 12, 2003 5:12 PM > To: [EMAIL PROTECTED] > Subject: RE: Forwarding control > > > Mike, > > Your suggestion worked out perfectly! Thanks for the help. > > One other quick question, if you don't mind - since sendRedirect() > doesn't send along the request object, is there another way to access > it from the target url while still using this method? > > Thanks, > > James > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Forwarding control
Hello, any help would be much appreciated. The basic scenario is as follows - I have a form page called form.jsp (http://localhost/webapp/form.jsp). Upon submission, the form data is processed by a servlet mapped to the url '/process' (http://localhost/webapp/process). Once the servlet has completed processing the form data, it forwards control to a results page (http://localhost/webapp/result.jsp) via RequestDispatcher dispatch = request.getRequestDispatcher (forwardPath); dispatch.forward(request, response); My question is this - although control has been forwarded to the results page, the browser's url is still http://localhost/webapp/process, which is ok with me; however, if the page is refreshed, the browser prompts for the form data to be resubmitted and the processing is repeated (which for my application happens to be quite substantial), rather than refreshing the contents of the results page. I suppose this is a minor annoyance that could be worked around by displaying a link to the results page rather than forwarding directly to it, but I'd rather implement the latter. Does anyone know of a solution or workaround for this problem? Thanks in advance, James - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Forwarding control
That's exactly what I needed to know. Thanks, Mike. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]