File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can I forward a local variable to another servlet?

 
Ken Shamrock
Ranch Hand
Posts: 139
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Adam Hardy
Ranch Hand
Posts: 567
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Set the variable as an attribute to the request.
request.setAttribute("myVar", localVar);
 
Ken Shamrock
Ranch Hand
Posts: 139
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh yes..thanks
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic