Re: Servlets, send redirect and request scope
What you are saying makes sense, except for the last part. Let me add a
little bit more pseudo code (note I have some of my code in there):
public class TestReconnectServlet extends BaseServlet {
doPost() {
String theKey = request.getParameterKey();
String theValue = request.getParameter(theKey);
Object arr [] = new Object[2];
arr[0] = theKey;
arr[1] = theValue;
session.setValue("mysession.before.redirect", arr);
response.sendRedirect(GoToFilter?);
}
}
public class TheFilter implements Filter {
public void doFilter(ServletRequest reqBasic, ServletResponse
respBasic, FilterChain chain) {
HttpServletRequest req = (HttpServletRequest) reqBasic;
HttpServletResponse res = (HttpServletResponse) respBasic;
/// Here ????????? build up the request object?
String key, value = session.getValue(arr);
request .setValue(key, value);
...
chain.doFilter(req, res);
}
}
Hmm, this might actually work?
response.sendRedirect(GoToFilter?);
When I do the redirect, it is to the GoToFilter?
Chris Smith wrote:
Berlin Brown <berlin.brown@gmail.com> wrote:
How would I do that. I know about filters. But what about in this
context.
Would I use the redirect to hit a 'filter'.
Yes. For example, you might use something like this:
1. Set a session attribute before you redirect containing the desired
request attributes and parameters.
2. Install a filter that intercepts all requests.
- If the session attribute doesn't exist, then just pass the request
along the chain without doing anything.
- If the session attribute does exist, then build a wrapped request
that returns the desired attributes and parameters, and pass that
along the chain.
--
Chris Smith