If I forward or include a servlet B from servlet A, req.getRequestDispatcher(forwardTo).forward(req, res); req.getRequestDispatcher(includeIn).include(req, res); besides forward the req (request) varible by user, can I forward a local/global variable declared inside Servlet A? (eg String a=test; can I forward this 'a' variable to another servlet by forward or include) ? Thanks
Set the variable as an attribute to the request. request.setAttribute("myVar", localVar);
I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
Joined: Jan 23, 2002
subject: Can I forward a local variable to another servlet?