my dog learned polymorphism
The moose likes Struts and the fly likes Application attribute in struts 1 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Reply 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: 2896
    
    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: 356
You can use following code,

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


Thanks,
Shailesh
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2896
    
    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: 356
OK, sagar.

 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Application attribute in struts 1
 
Similar Threads
How to use, struts 1-- struts-config.xml and struts 2 -- struts.xml together?
Struts 2 questions
Book for one who does not know Struts 1?
Example WS with Struts
A Query about accessing EJB from my Struts2 Action class