File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Application attribute in struts 1