Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to share a context (Struts and servlet)

 
Andrei Antonescu
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have a application coded in Struts. I want to install a servlet on the same app that has

Is there any way to send data from the Servlet to a method called in the Struts portion of the app?
I have tried (in the servlet):

And in the struts action:

with no luck.

Thanks in advance
 
Krishna Madhava
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

you can share the data between servlets and struts like below...

in servlets set the data::

request.getSession().setAttribute("data","content");


in struts 2 action class get the data:::

using ActionContext

ActionContext actionContext = ActionContext.getContext();
actionContext.getSession.get("data");

I hope it should work..

Thank you

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic