| Hey! | hi!
| I do this all the time, if I am understanding your requirements | correctly. | | I use the Model View Control. I have Control servlet that has a doGet() | that sends back the appropriate View JSP FORMs page requiring attributes to be | filled in and submitted by the client. The Control servlet extracts the | attributes | in the doPost() and it directs it to the appropriate Model object for | processing. | When done, the Control servlet sends back a response to client to the View JSP | but now it has Model data (possibly in a session object) for display. | that's exactly what i do!!! but after the redirect the client resends the data entered into the form once and then requests the "view servlet". well, i have a workaround and everything works like it should, but i just don't get why that happens... | I still believe the way you are trying to do it is problematic. why? because i don't use a jsp to manage the view, but instead have a servlet processing WebMacro templates to create html? michael weller | | Sans adieu, | Danny Rubis | | Michael Weller wrote: | | > | Hey! | > | > hi! | > | > | | > | There is all type of trouble you can get into with sendRedirect()s. You | > | are probably already aware that this takes two trips over the network | > | to get the job done. Without seeing you code, I suspect that the flow | > | of the events in your code have an error. | > | | > | > that is my intension. i use sendRedirect because this way another req is | > made with *no* attributes. | > the first request is done to send the data, server does anything with the | > data, sends a response to redirect the client to the url where it can | > requests the results from. the problem is that after the response the client | > gets it seems that the client resends the same request (as it did before to | > upload the data) once, and *then* it requests the url specified in | > res.sendRedirect(bla). | > it should work this way: | > client sends data --> server sends redirect --> client requests page | > specified in sendRedirect | > but it works this way: | > client sends data --> server sends redirect --> client resends data --> | > server sends redirect --> client requests page specified in sendRedirect | > | > | I suggest that you use RequestDispatcher.forward(). | > | > i'd get an infinite loop then ( if i wouldn't remove all attributes)... | > | > michael weller | > | > | | > | Sans adieu, | > | Danny Rubis | > | | > | Michael Weller wrote: | > | | > | > hi, | > | > i have a problem concerning response.sendRedirect(aLoc). i use resin | > 2.0.3. | > | > the javadocs for this method state "Sends a temporary redirect response | > to | > | > the client using the specified redirect location URL.". my | > interpretation of | > | > this is that the client receives a response from the server indicating | > which | > | > location the client has to request in order to get his original request | > | > fulfilled so the client does another request. | > | > here's the problem: | > | > in a webapplication i have a servlet receiving a post form, the data | > entered | > | > �n the form is subject to some computations, the results of that is | > stored | > | > in the user's session. then i use res.sendRedirect(theURL) to send the | > | > client to the servlet that will render the results to html. if i do so | > | > there's no output, instead the computation is done another time, and | > then i | > | > see the output. | > | > if I add the following lines before the res.sendRedirect(...) | > | > Enumeration enu = req.getParameterNames(); | > | > while (enu.hasMoreElements()) | > | > req.removeAttribute((String)enu.nextElement()); | > | > everything works all right. | > | > why do i have to remove all attributes from the request object before | > doing | > | > the sendRedirect? i thought that they were removed anyway, because the | > | > client sends another request (with no attributes) to get the results. | > | > | > | > thanks for your help in advance! | > | > | > | > michael weller | > | > | > | > ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
