Dynamic URL update in deployed web app - java

What I have ?
Two web applications which inter-communicates using sendRedirect
What I want ?
To deploy those web apps on AWS
Problems
1) When I am deploying one web application to AWS , I dont have url of second web application because it is not deployed yet. I must need to specify url of second web app so first web app can communicate with second web app.
2) I can not deploy second web app initially because it also redirects to first web app (inter-communication ) i.e. If i deploy second web app initially problem continues because I don't have url of first web application
Straight Solution
1) Deploy first web app with dummy url of second web app. (Here I wll get actual url of first web app)
2) Deploy second web app with actual url of first web app (Here I will get actual url of second web app)
3) Update first web app with actual url of second web app and redeploy the first web app
Above solution is time consuming and needs rework.
Is there any efficient way by which I can dynamically update the url
used in web app , and no need to redeploy app

Don't know the knitty gritty details on how it can/should be implemented exactly but I would look for a kind of publish/subscribe mechanism in which both Web servers are initially booted and listening for each other. The web server remains pending until it receives a notification the other is ready to receive messages. When one of the web servers is ready to receive messages it will publish a notification. Once the other web server is ready it will receive the notification (containing the URL at which it can be received) and publish also a notification that it is ready to receive messages.
Another possibility would be create load ballancers for both web servers at a fixed address. When the web server is started it will be added to the load ballancer hiding where the server exactly is deployed.
Hope this makes sense to you.

Related

Redirect All Request from web server to another

I have to make an application in tomcat which core responsibility is to redirect all request coming from browser application to API server. It works like proxy server between browser application and API application. Have to write it on tomcat. How can i achieve this, do i have write a REST API application on tomcat too?
Project Description
Requirement is like we have two application one is developed on React, its a web-portal and the other one is on spring-boot as a backend application (json apis).
spring-boot application is going to be deployed on secure zone and web-portal is in DMZ. web-portal in on internet, backend application is on intranet. As web-portal is a CSR application so the api's calls from web-portal contains backend application IP/URI but it cannot be accessible from internet.
So i am planning to write an application on DMZ zone and it will be deployed on apache tomcat, so like when request comes at tomcat it redirect it to backend application server which is on intranet with all headers/payload and redirect response from backend server to web-portal.
You want to set up a reverse proxy which is a standard pattern. Take a look at the answers at Reverse Proxy Java or just search the web for "reverse proxy java".
If you are not bound to implement it in java take a look at Nginx which we use in many projects to transfer the request from the web app to the REST backend.

How to call a method when a jsp web application starts on tomcat server?

Having a jsp web application on a tomcat server, how can I call one of my java methods when the server starts? I mean without opening the website using a navigator... just doing it when the server starts, for example, after a reboot of the server I want to start some jobs, without entering the website, just automatically when teh server reboots and the jsp web application is loaded by tomcat.
How can I do that?
Can't find any info about that

How to restrict access to web pages in the explained matter?

I have a web application developed in pure JSP and Servlet. Application can be deployed local servers and run. Now we have a requirement where we will get a notification as soon as someone deployed the application in their server. The application will send us the IP address of the machine which the application is deployed.
We wrote a ServletContextListener and added the code into it, so it will execute only once in the apps life time.
Now for the above thing, internet connection is must, that is OK. But the issue is the application should not give access to the web pages/ servlets if the notification is not sent to us.
I know this kind of thing can be done in desktop applications, but how to do this in web applications?

GAE or just simple Tomcat Server, which should I take?

I have been working on a small Web RESTfull APP that will provide urls to create user to a database and offer signing procedure (validate email/password against database). The target client to this web app will be Android devices, from my mobile application. Once the mobile app invokes the AP and response(in JSON format is received), I parse the response, and the user proceeds with the rest of the mobile app.
At the moment I am thinking deployment. For my development, the app is deployed to a Tomcat server but I know war archives can also be deployed to Google App engine.Being a newbie in webapps, I kindly need your suggestions.Should I deploy to a Tomcat server or to Google App Engine? Is any of these methods better than the other and why?
Thanks.

Access a web application running on one server from a different web application running on another server

I have developed a web application (say webapp1) running on server (say server1 ).
I have another web application (say webapp2) running on different server(say server2).
Only registered users on webapp1 must be able to log in to webapp2 using username and password from webapp1 session.
webapp1 using active directory to authenticate users. Some users of webapp1 can access webapp2 by internally going through active directory.
I want to access webapp1 fron webapp2. How can I do that?
I think you question is something like this. You have two web apps and when a request comes in your first webapp1 does some processing and other part to be done by second webapp.
This can be done by redirecting/forwarding the request to the second webapp, let the second webapp complete the remaining part of work and return it to user or to the first webapp again.
You'd want to create an API to do this.
See a similar question (for PHP but the basic concept still applies): create api using php
Build RESTful web services with Java technology:
http://www.ibm.com/developerworks/training/kp/j-kp-rest/index.html

Categories

Resources