Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) 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

 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!