HTML5 and Java server application deployment on AWS - java

I have created a Java restful server application which can be compiled as a JAR/WAR file and I have another front-end application built using knockoutjs and HTML5 which talks to the Restful Server side application.
I am trying to deploy both on to Amazon Linux AMI EC2 Instance. I was successfully able to deploy the JAR after setting up a glassfish server on the server. The server side application is running completely fine.
I am having problems in understanding how the HTML5 application needs to be deployed on the AWS server. So that both can be accessible from the same server.
It would be great if some best practices are also suggested.Appreciate any help
Thanks

You probably want to put your GlassFish application server behind an HTTP server like Apache HTTPd or nginx, and either of those servers could then also serve your static content -- your HTML and JS. Check out http://www.codefactorycr.com/glassfish-behind-apache.html

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.

Configuring Java Client for Hazelcast

I am trying to configure a JAVA client for Hazelcast. I have a web application deployed on tomcat servers. The example that I am following is this
Basic Clients Hazelcast. I have copied the code into my local machine and when I simply run it without running anything else and without the addAddress() step I get a java.net.ConnectionException. My doubts are:
1) What is the client in this case (I am assuming it is the web application that probably means I have to get the Hazelcast server up and running then what is to be done)?
2) How do I establish a link between the web app, the tomcat server and hazelcast cluster? The web app uses MongoDB as the backend. I was able to do a only MongoDB with Hazelcast integration but not the web app on tomcat server integration. What role does tomcat play here in this setup?
3) In the example what are the start.sh and stop.sh supposed to do? Where should I run them? If I simply open the git bash and run it. It doesn't seem to work.
I have looked at the documentation provided in the Hazelcast manual but I wasn't able to understand it as my current level of knowledge is woefully inadequate. If somebody could explain it to me or paste the links to some of the obvious stuff that I should know it would be great.
The answers are inline:
What is the client in this case(I am assuming it is the web
application that probably means I have to get the Hazelcast server up
and running then what is to be done)
The web application can be a Hazelcast client if you would like to use Hazelcast in client-server topology.
How do I establish a link between the web app, the tomcat server and
hazelcast cluster. The web app uses MongoDB as the backend. I was able
to do a only MongoDB with Hazelcast integration but not the web app on
tomcat server integration. What role does tomcat play here in this
setup.
Your web app runs in Tomcat server (web container) and the Hazelcast client you use in your web app can directly connect to the Hazelcast cluster members (server). You will just need to configure your client properly such as adding cluster member address by using clientConfig.getNetworkConfig().addAddress() API. Please see for more details about configuring client in this link: http://docs.hazelcast.org/docs/latest/manual/html-single/index.html#configuring-java-client
In the example what are the start.sh and stop.sh supposed to do.
Where should I run them. If I simply open the git bash and run it. It
doesnt seem to work.
Those are sample start scripts for the sample client and member application. You don't need to use them in your application.
Please see the following guides for using Hazelcast in client-server topology:
https://hazelcast.org/getting-started-with-hazelcast/
http://docs.hazelcast.org/docs/latest/manual/html-single/index.html#getting-started-with-java-client

Convert java project to apache-tomcat hosted project

I created an application that is running locally without server. It recieves data through a socket, processes it and then sends the result back.
I want to host it on a local apache-tomcat server using Eclipse, and I already created the server.
How can I run the program on the server ? Do I have to convert the project to a web project ?
Couldn't find any tutorial except for webpage-creating projects...
Thanks
If you're already using sockets, there is a good chance Tomcat won't be serving your needs. As for web application projects, you need to use, e.g. Servlets to serve requests on server wrappers like Tomcat.

How would I/can I post a java web project from Netbeans to Sharepoint?

I have a java web application that I am developing in Netbeans (and running through Tomcat). Is there any way to put this application on Sharepoint?
This is my first time doing this. I've read that to post the application to a tomcat server you just have to copy the .war file over, but I haven't been able to find an easy solution for Sharepoint.
Sharepoint isn't a Java Application Server. You'll have to use Tomcat (or another Java Application Server) to host your application. If you need to interact with Sharepoint from your application, you'll have to use web services, a shared database or something else to communicate.
That's not possible out of the box. SharePoint only runs ASP.NET applications, not java projects.
You can deploy the solution to a Tomcat server and then use the Page Viewer Web Part to show external content.

running php and java on the same server

I have web services written using java which interacts with the android application only now we need to implement a front end web portal using php frame work codeigniter. We have common database mysql 5.1 which interacts with both the web services and also web portal, is it possible to configure the LAMP stack in a server which is already running tomcat6 servlet container but with out apache web server. How do I processed further and when Iwas search for same issuse I found something called php java bridge is that what I have to use??
Let me be more precise on this, I have ec2 ubuntu instance already running, domain is parked in godaddy, i have configured the A records with the ip of my ec2 instance, so when the requests comes in it will be directed to the application which is running in the tomcat6/webapps/ROOT but now I need to redirect it to the php application how do I do it and also requests from android should be directed to web services which are java based, how do I manage this?
Kindly help out
You can proxy requests to the tomcat server from Apache ... have two virtual hosts, one for the tomcat and one for the php ... all co-ordinated by apache.
http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html
It is recommended that you also read the Workers HowTo document to learn how to setup the working entities between your web server and Tomcat Engines. For more detailed configuration information consult the Reference Guide for workers.properties, uriworkermap and Apache.

Categories

Resources