• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Application attribute in struts 1

 
divya kundapur
Ranch Hand
Posts: 110
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to set application context attirbute in my struts action class and use it later in another jsp. I m using struts 1.
 
Sagar Rohankar
Ranch Hand
Posts: 2904
1
Java Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use following code,

this.getServlet().getServletContext().setAttribute("name",value);
 
Sagar Rohankar
Ranch Hand
Posts: 2904
1
Java Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a good thing by directly providing a code, let them search the API and come up with their solution.
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, sagar.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic