passing object from servlet to action servlet
1 posts in topic
Flat View  Flat View

Posted By:   sender_jones
Posted On:   Thursday, July 16, 2009 11:30 PM

I have an app that use both servlet and struts action servlet. Is there a way to pass an object, say using setAttribute() , from a servlet to, say using getAttribute() , an action servlet?

In a servlet, I getServletContext().getContextPath() and in an action servlet, I request().getContextPath() , both return the same string. But if I getServletContext().setAttribute(name, obj) in a servlet, I can't obtain my obj by request.getServletContext().getAttribute(name) in action servlet. It returns null. Please help.

Re: passing object from servlet to action servlet

Posted By:   Shailesh_Yadav  
Posted On:   Wednesday, July 22, 2009 04:51 AM

When you are setting data in ServletContext then you have to retrieve it only by using servetletcontext. Try using ServletContext.getAttribute(), this will work.

I think better to use session, request or application object.

Can you please let me know why you want to use ActionServlet for such a easy task?
About | Sitemap | Contact