dcsimg
sendRedirect vs forward, (while setting an attribute), forwarding to a page with a custom tag
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   ben_jessel
Posted On:   Tuesday, March 5, 2002 07:06 AM

I've got a servlet that should set an attribute object in the request. I then want to forward to a page with a custom tag who's job is to get this attribute and display the attribute object's details in a nice format. If I use sendRedirect - then the attribute that I have just put in the request is forgotten (as the server asks browser for a new request). If I use getRequestDispatcher("somepage").forward(res,req) , then I have to have committed my output buffer - from what I can tell you cannot write to the output writer after a forward. So I cannot do any writing in my custom tag. What should I be using? :-(    More>>

I've got a servlet that should set an attribute object in the request. I then want to forward to a page with a custom tag who's job is to get this attribute and display the attribute object's details in a nice format.

If I use sendRedirect - then the attribute that I have just put in the request is forgotten (as the server asks browser for a new request).

If I use

getRequestDispatcher("somepage").forward(res,req)
, then I have to have committed my output buffer - from what I can tell you cannot write to the output writer after a forward. So I cannot do any writing in my custom tag.

What should I be using?
:-(    <<Less

Re: sendRedirect vs forward, (while setting an attribute), forwarding to a page with a custom tag

Posted By:   Anonymous  
Posted On:   Tuesday, March 5, 2002 07:31 AM

Are you saying that after you set your attribute in te request object and you do:

req.getRequestDispatcher("somepage").forward(res,req);

you get an IllegalStateException because you have already flushed the buffer and you are attempting to change the headers of the response object?


Regards

About | Sitemap | Contact