This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to share a context (Struts and servlet)  RSS feed

 
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

 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!