• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Two Web App communicating problem

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

Here i am using Apache Tomcat 6.0.16. I have 2 Web App Hello1 and Hello2 each having 2 servlet. The relevent content of first servlet is:



And for secondnd servet is:



I had put load on start up value 1 and 2 for both servlets repectively. Here is relevent content of server.xml



And here is output consol:



Now please can anybody help me in finding out the reason of why i am not getting the context of first app(Hello1) in second app(Hello2)


This is 2ndservlet
This is First contextnull



It is coming as null. Any suggestion most welcome. Thanks in advance.

Regards
Divya garg.
 
Sheriff
Posts: 9709
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Divyyyyy please check your private messages for some administrative matter...
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the javadocs of ServletContext.getContext:

In a security conscious environment, the servlet container may return null for a given URL.



In Tomcat you can get around this by setting the Context's crossContext attribute to true.
 
Garg Divya
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks for your reply. It was quite helpful. But my requirement is little changed now. Using Servlet context i can not get the session synchronization between two app because of some security issues. Please can you suggest me the best way of getting session synchronization between two app.

Thanks,
Divya Garg


 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean by "session synchronization"?
 
Garg Divya
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok let me elaborate.

I have a link in my page. As i click on that link my application get an attribute from from other app running on same server. But that attribute is set on application level on other application. so now the problem is if a user(same session) try to access my application on different timing, he will get different value of attribute because that attribute is dynamic with time. But i want a unique value for a user.

So now i have decided that i will use a Map or Hashtable to store a session id as key and attribute as value. So that every user would get a unique attribute. This is my idea. Can you suggest me is there any drawback in my approach related to seurity or performance something.

Thanks,
Divya garg
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So there will be one value for each user, and that value should be unique across different web apps running on the same server? Where does this value come from, and how often does it change? Could it be stored in the DB along with all the other user information, so that all web apps can get at it?
 
Garg Divya
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes there will be a unique for every user, this is primary requirement and that value will be like timestamps which will change every second. It will finally be stored in database.

Thanks,
Divya Garg
 
Garg Divya
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Sorry for late reply. Actually today i have discussed things with my PM. My task is little extended. I can not work on session ids. What i have to perform now is if a user log in from another browser then he or she should be in same session as he was in previous browser on the same application.

I mean to say is that a user is access the page and that page have an attribute value which is dynamic with time. Now problem is if the same user access the same page(after some time) by typing URL path of that page on different browser then he should be getting the same attribute value as it was previously.

By default we we log in our application from another browser then it logged in other session. So is there any technique to perform it?. Any suggestion regarding this? Thanks in advance.

Regards,
Divya Garg
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like you will have to implement your own "session" object that tracks the user state. Make it serializable and write it to a common file space or database using the user's unique key.

Bill
 
Garg Divya
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

Thanks to all for your reply. My previous task is finished. Now my task is little more extended. Now i have been instructed that one of my application is deployed on one machine and i have to access its context in another app deployed on another server. So i think now i will have to use JNDI.

Since i had done some work on EJB with JBoss where we use JNDI and we bind HomeInterface to JNDI logical name and by that name we access that Home Interface in the code.

Here is that JNDI Code:





Here we can give the ip(in place of localhost) of web server.

In the same way now i will have to bind the servlet context of on application to JNDI Logical name. And through that name i will access the servlet context in another app deployed on another server. But now the problem is I m not getting sufficient coding based help from anywhere. Please can anybody provide me any of type help on this topic. Thanks in advance.

Regards,
Divya Garg
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Out of curiosity..
Why are you spreading things out over multiple web applications?

This is one area where the servlet spec (I haven't finished the spec for 3.0 so this might have changed) is not very specific.
Not specific means that behavior tends to be different from app server to app server, meaning that your app is not going to be very portable.

reply
    Bookmark Topic Watch Topic
  • New Topic