This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 365
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: 365
OK, sagar.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Application attribute in struts 1
 
Similar Threads
A Query about accessing EJB from my Struts2 Action class
Example WS with Struts
Struts 2 questions
How to use, struts 1-- struts-config.xml and struts 2 -- struts.xml together?
Book for one who does not know Struts 1?