wood burning stoves 2.0*
The moose likes Struts and the fly likes Application attribute in struts 1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Application attribute in struts 1" Watch "Application attribute in struts 1" New topic
Author

Application attribute in struts 1

divya kundapur
Ranch Hand

Joined: Aug 21, 2007
Posts: 110
I want to set application context attirbute in my struts action class and use it later in another jsp. I m using struts 1.


SCJP - 5.0
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

divya kundapur wrote:set application context attirbute

Either define the context variable in DD (web.xml)
OR get the instance of javax.servlet.ServletContext and use "setAttribute()" method.

HTH


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 368
You can use following code,

this.getServlet().getServletContext().setAttribute("name",value);


Thanks,
Shailesh
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Not a good thing by directly providing a code, let them search the API and come up with their solution.
Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 368
OK, sagar.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Application attribute in struts 1