• Post Reply Bookmark Topic Watch Topic
  • New Topic

Access attribute of other Web Application

 
Haroldo Nascimento
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible access atribute set in a web application e access in jsp and servlets of the other web Appliation in the same web Server ?
 
Leandro Oliveira
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can have access to another ServletContext (other web application) by calling the instance method: ServletContext.getContext("pathOfOtherContext")
I'm not sure but I think that you have to do some additional configuration to have this working!!
maybe someone in the forum can tell us more about it...
 
Leandro Oliveira
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And, notice that servlet 2.4 documentation say nothing about set attributes in other contexts, it says about getting a javax.servlet.RequestDispatcher to the other context! and these application must be hosted in the same container!

Hope it helps!
 
Haroldo Nascimento
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is any possibility that ServletContext lost ou replace the attribute if others Users login in the Portal ?
Obs.: Every login I put in the ServletContext you Perfil.
Ask you because I know that session is per browser then I dont have this problem, but to put the Perfil on the ServletContext I dont know.
 
Leandro Oliveira
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Haroldo
Try to separate ServletContext and HttpSessions, ServletContext is the java representation of the application, and HttpSession is the java representation of a stateless session (statless protocol, HTTP). A session is just shared between contexts if you are inside a distributable application, also notice that the session will only transfer between context (the full object), there is no way to have parts of the session shared between containers, Take a look at HttpSessionActivationListener.
feel free to send me an e-mail, or a private message, in Portuguese if you preffer, maybe I can have more chances to help you using your native language (Portuguese isn't it?).
 
chinnu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am looking for similar thing to work.Can anyone be more clear on how I can make this work by maintaining the session for the servletcontext attributes....
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!