6

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.

4
  • Why do you want to split static and dynamic content? Is it an organizational consideration or do you want to improve performance? Commented Sep 18, 2012 at 9:50
  • Thanks for the comments and i appreciate each and every one's comments. Nice learning curve for me. I want to use both HTTP server and Application server for improving the performance of my web application. I have been reading a book named "Performance Analysis for Java™ Web Sites" for a while now. And its recommending me to put my static content in HTTP server and Dynamic content in Application server. But i am not aware of how to do that practically. All i know is how to build a WAR file and deploy in Tomcat which is a App server we are using for our deployment. Commented Sep 18, 2012 at 10:31
  • So my question can be modified as below. How do i deploy my static content in a HTTP server? If i get some help on this then i can go ahead and remove all my static content from the WAR file and deploy it in HTTP server and the rest of the files inside the WAR in the Application server. Commented Sep 18, 2012 at 10:31
  • You'd just have to set up an Apache server or similar, and put all your images/css/js/other static content (NOT JSP/JSF) in its configured folders. I do NOT recommend doing this, I have serious doubts that any performance gain would be noticable, especially if it's just a few css/js/image files. These are cached on the client web browser anyways, so it's not a big issue, while you'd have do deal with a lot more work to set this up and maintain it. The one scenario i could imagine this being close to a good idea might be if you serve a lot of large files. Commented Sep 18, 2012 at 11:07

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

How do i deploy my static content in a HTTP server? If i get some help on this then i can go ahead and remove all my static content from the WAR file and deploy it in HTTP server and the rest of the files inside the WAR in the Application server.
0

You can not deploy WAR file into HTTP server. A WAR is used for Java web applications it must be deployed into application server or servlet container (like Tomcat). I don't think that its a good idea to separate static content in a separate web application. If this is one project it should be one web application, besides:

A WAR file has a special folder structure and contains special files in addition to JSP pages, Java servlets, Java classes, HTML pages etc. which combined forms a Web Application.

You can hold your static contents in your one application and there is really nothing bad about it.

If your project is very huge and has a lot of files it is no problem, you just need to use the project structure like that, that it should be easily understandable and readable and the application server or servlet container will take care of deploying as many contents as there is.

1 Comment

I appreciate your inputs...But my requirement is to deploy my static content into a HTTP server to improve performance of my web application. I am not sure how to bundle and deploy the static content in the HTTP server and access it from JSPs inside a WAR file which is deployed on a Tomcat container. Any help on this will be great...
0

Up to version 4, Tomcat has been quite slow in serving static content. This is why it was frequently recommended to split dynamic from static content and serve the latter using a regular web server (the book you mentioned was issued in 2002...). Recent Tomcat versions do not face this problem, thus you can IMHO refrain from splitting, which can be a nightmare for both organization and security.

For static resources, you might rather focus on configuring proper caching, so they will not be transferred more often than necessary.

2 Comments

Yeah Caching is one more area which i wanted to look at too. In fact we already started looking at for frequently used master tables related queries and some caching approaches for them. One approach is to load the results of these queries in-memory during web application start up time and use it. One issue is to refresh the in-memory stuff when the master table data changes...But will look into this caching issue separately...just wanted to share that we are looking into that aspect too...
Caching data from db is a different issue - I meant setting cache headers for static resources in the web server, so browsers will only fetch them once.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.