Wyn Easton wrote:

> Hello,
>
> Could someone help me understand the following
> situation?
>
> I have two servlets (s1 and s2) and one jsp (j1).
> If I do this in s1:
> request.setAttribute("str1", "Hello");
> then forward to s2:
> ...forward(request,response);
> In s2 I do this:
> request.setAttribute("str1", "So Long");
> then forward back to s1:
> ...forward(request,response);
> Now I do this:
> String str = request.getAttribute("str1");
>
> str now contains "Hello" not "So Long".
>
> But, if I do this in s1:
> request.setAttribute("str1", "Hello");
> then forward to s2:
> ...forward(request,response);
> In s2 I do this:
> request.setAttribute("diff1", "Different");
> then forward to the jsp (j1):
> ...forward(request,response);
> Now I do this in j1:
> String str = request.getAttribute("diff1");
>
> str contains "Different".
>
> Is the request suppose to allow me to change it
> after I forward?  Or am I not allowed to change
> stuff already bound to the request, but I can
> bind new stuff?
>
> Thanks for any insight.
> [...]

Hi :-)  I am not sure, I guess:
 -  in s1(first time), request.setAttribute("str1", "Hello")
 -  in s2, request.setAttribute("str1", "So Long")
 -  in s1(second time),  now I just guess that the following
    line "is run again":
    request.setAttribute("str1", "Hello") ;

    so you still get "Hello" in s1(second time). The above
    is just my guessing, if it is noe right, please omit it. and
    I find when I RequestDispatcher.forward(request, response)
    to another Servlet in the same webapp, the original
    HttpServletRequest and the new one are Different(thay have
    different hashcode).


Bo
Mar.29, 2001


Reply via email to