Communication between servlets in Java - java

I have two web application running on same server.
I want to send objects from one servlet in Application1 to another servlet in Application2. How can i do that?
Will the session object be same for both the app if running on same
server?
How can i share the session object across the applications?
What if both web applications are on different server?
Please provide link of any good article which address the above issue since i am unable to find one.

Related

Can java access ASP.Net Session Data in Memory if both apps are on the same server and Java has the Session ID?

I am building a java Rest Service that is located on the same server as a .Net application. The client is hosted within the .Net Application but it communicates with a Java Rest Service. We need some way of accessing the Users Session data in .Net without altering the .Net code. So my question is...
If the java Rest Service app is located on the same server as the ASP.NET app. This means ASP.NET is saving the users information on the servers memory. If we have the Session ID. And its past to java, is it possible for Java to retrieve that information in memory by using the Session ID ?
In general what are my possibilities.
The java application and the ASP.NET application are both on the same server and on a windows server.
Thanks

Session sharing between different webapps in Jetty

I have two webapps loaded from one embedded jetty server. Both apps are using Spring MVC.
Sessions are managed by manipulating HttpSession objects in the controller methods.
(request.getSession() and session.invalidate(), etc)
But suppose a user signs in on web app A, and session is created on web app A. When the same user hits web app B, can the app read and recognize the same session that's being used in A? Or do two web apps have completely separate session managements? I see the browser stores a JSESSION cookie, so I wonder if two apps would use the same JSESSION cookies?
I did search around and had no luck, probably related to embedded jetty having mutliple apps is a bit uncommon.
Thank you so much!
There is answer in scope of tomcat, but looks like the same is possible for jetty

Single sign on Java and NodeJs (Share single session object between Java and Nodejs)

I developed two application. One application developed by using Java(Spring MVC and Spring Security) and another application developed by using NodeJs.
I would like to integrate NodeJs application in Java application(Spring framwork application) . I would like to access(Call) the NodeJs application after login into Java application.
I checked in forum but I am not get in clear view.
E.g) My situation is, I have one hyperlink in Java (Hyperlink will show after login) and call NodeJs application if user click on that hyperlink.
Can you please give the some examples and ideas for integrating NodeJs and Java applicaton and also for sharing session between Java and NodeJs application?
You can just put your web apps behind proxy server to avoid the CORS problem and for sharing the session you would use Redis DB.
After it you will need just to check session expiration on your NodeJs app.

How to host JSPs on a web server?

Hi I'm sorry for the naivety of this problem but I need some guidance as I have confused myself greatly.
I have been tasked with creating a database(mysql) and creating a web interface for i to be interacted with. I have experience with web design and database development. Previously I have used java to interact with a DB and was hoping I could use JSP for the web interface. This is where my problem is, how I would I deploy/host this website?
I have 2 theories which are misguided:
(A). Use a cms which has a web server for me to place the jsps in?
or
(B). Use a domian/web hosting site that has a server for me to place the jsps in?
I'm totally lost and any guidance would be greatly appreciated.
Simple answer is you will require a Java Application Server to host your JSPs.
You can use Apache Tomcat, GlassFish, or some other application server to do this.
You will also need a database e.g MySQL running on your host or some other host accessible by the machine running the Java application server.
You can choose to host all of this locally or farm it out to a web host provider depending on your resources.
A CMS seems like overkill. See this link for a description of CMS and its functionality. I don't believe this is what you are looking.
I don't know exactly what you're looking for, but I think you need (B)
You need a MySQL instance running your database and a servlet container (e.g. Tomcat) to host your JSPs.
Running a CMS which is just used to use the DB that it works with is a little bit heavy for that usecase.
As suggested by Mr #cmd , yes there is no need to go for an outsourced server just to host your website, unless you need it to be visible to the world.
Else for your testing purpose, you can use Any of the Apache Tomcat, Glassfish servers for hosting the applications designed in JSP or in other web interface language.
And Inside of the JSP coding itself you may write the interaction coding with your database.
your database also can be installed in the same server.
And actually instead of a server, you may even use your PC to install the Apache Tomcat and the database and start using it.

Java web application on apache tomcat

I am developing a web application in java using the Vaadin framework.
I am running that application on Apache Tomcat. What I want to ask is that, if I run that application on Apache Tomcat and access the same application using two different browsers on two different computers, then does the application then have two instances on Tomcat or does it have a single instance?? I have searched for it, but not been able to find a satisfactory answer.
Thanks !
If you run a web application in Tomcat, you'll have exactly one Tomcat instance, which will host your application. This single Tomcat instance (and therefore your web application) will be able to many different browser requests, from many different computers. This is exactly what web servers are designed to do: process requests from many different clients.
One instance of Tomcat, and many instances of your Vaadin app.
To access your Vaadin app, the user points their web browser to your Vaadin app's URL. Tomcat must already be running in order to accept the request from the web browser. When the already-running instance of Tomcat receives that request, Tomcat starts a new thread. In that thread a new instance of your subclass of the Vaadin "Application" class will be created and run.
So, if you have 5 simultaneous users running your Vaadin app, you will have one instance of Tomcat running. And that Tomcat instance will be running 5 sessions, each in its own thread running its own instance of your Vaadin "Application" subclass.
Anything marked "static" in your app applies to all 5 instances of your app, while anything not marked "static" applies only to a single instance of your app (a single user).

Categories