Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use both http server and application server in a java web application

I have some deployment model question for a Java EE web application. Currently we are deploying our web application as a WAR file in Tomcat 6. All the content is packaged with the WAR file including the static content like images, static html pages and so on. But i want to deploy these static content in a HTTP server and use the Application server only for retrieving the dynamic content. How do i split these things? Does any one has done any thing of this sort and have a good deployment model for my scenario. Help will be appreciated.

Is it a good idea to make 2 WAR files one with only static content and deploy that WAR in HTTP server and the rest as a different WAR file and deploy it in the Application server? But this approach will have impact on all the pages where the static content is currently referred and requires code changes which is very cumbersome since our project is Huge and the code based is very very big.

Any strategy and ideas are welcome.

like image 305
Amjath Sharief Avatar asked Sep 18 '12 09:09

Amjath Sharief


People also ask

How web server and application server works together?

How Do Application Servers and Web Servers Work Together? In a typical deployment, a website that provides both static and dynamically generated content runs web servers for the static content and application servers to generate content dynamically.

Is webserver and application server same?

The main difference between Web server and application server is that web server is meant to serve static pages e.g. HTML and CSS, while Application Server is responsible for generating dynamic content by executing server side code e.g. JSP, Servlet or EJB.

Is Apache HTTP server an application server?

Simply put, Apache HTTP server is a web server designed to serve static web pages. Whereas, Apache Tomcat is an application server built to serve java applications.

What is the difference between web server and application server in Java?

Web Server is a server which accepts a request for data and sends the relevant document in return whereas Application Server contains a ejb container component as well to run the enterprise applications.


1 Answers

This can be something interesting to do for performance reasons.

You should have separate deployment scripts / deployment files to do this. Having multiple file/WAR/folder/scripts to deploy for one project is not an issue. We have the same thing when you have to deploy your WAR and to update your database.

I would have a WAR file and a folder with your static content to deploy.


Edit

Deploying the static content in a HTTP server depends on the server. If you want to use Apache on a Linux server, you have to set up a Virtual Host.

<VirtualHost *:80>
  # This first-listed virtual host is also the default for *:80
  ServerName www.example.com
  DocumentRoot /www/domain
</VirtualHost>

In this example, you have the a virtual host that listens on 80 port, for any IP address and for the server name www.example.com. Then this is redirected to the /www/domain path.

You will find much more examples and configuration options in the documentation.

like image 189
Florian Parain Avatar answered Oct 05 '22 11:10

Florian Parain