• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

need to put static contents and generate a war

 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just have to deploy HTML,CSS and Javascript on the tomcat on RHEL server. So I want to create a WAR file.

I have Eclipse and wondering if I should create a Dynamic Web project and put all the static file contents inside WEB-INF directory? In this case, would I be able to create a WAR locally and deploy it on the Eclipse Tomcat? Would it show up in the Add / Remove options?


OR

Should I create a maven project and then put static contents?
 
Ranch Hand
Posts: 47
Android Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a Maven project the content from src/main/webapp is copied to the root directory of the war file.

Example:

in mywebapp.war


URL - depends on mapping of mywebapp.war
http://host:8080/mywebapp/js/main.js
http://host:8080/mywebapp/ or http://host:8080/mywebapp/index.jsp
 
Saloon Keeper
Posts: 24295
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I recommend (as Roland implies) that you create the project as a Maven project. Project building in an IDE should be a convenience, not mandatory. I have scars to prove it.

Use the maven /src/main/webapp to hold the static content that you want copied into the WAR. Do NOT put anything into WEB-INF that is to be accessed by a client URL request, such as CSS, image or Javascript files. WEB-INF and its children are invisible to the client and can only be accessed by code running in the server (preferably via the HttpServletRequest getResource() method). So you'd keep things like config files there, since clients shouldn't be able to access them for security reasons.

I never use the Eclipse Dynamic Web project stuff myself. I've never been able to without getting into fights with it. I just do a regular project with a Maven WAR POM file.

As for running Tomcat, there are several ways to do that. The most obvious - and worst way - is to use the WTP plugin that's pre-installed with the JEE spin of Eclipse. I prefer the Eclipse Tomcat plugin myself (formerly know as mongrel, formerly known as sysdeo). I can set up my Tomcat server to see the WAR directory under target directory in my Maven project and run straight from there without having to manually deploy it.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic