[+cc maven-users]

I'm sorry I'm not particularly good at telling people "what they should
do". What I'm god at is telling you how things work, and then let you make
the changes to achieve your goal (knowing where you come from and where you
want to go).

You have to understand the structure of a WAR file, and how you want *your* WAR
file to look like. First, a WAR file is in ZIP format, if you open your WAR
file with WinZIP (or rename it as *.zip and open it as a "compressed
folder" in Windows Explorer), here's what it looks like:

   - the webapp descriptor lives in WEB-INF/web.xml
   - compiled classes can go into WEB-INF/classes (as
   WEB-INF/classes/com/example/MyClass.class, for a class MyClass in package
   com.example)
   - third-party dependencies go into WEB-INF/lib (as JAR files directly
   inside the directory, with no additional subdirectory)
   - web resources go outside the WEB-INF and META-INF directories.
   Generally, you'll find an index.html or index.jsp file at the root of the
   WAR. Put your files as you like, as long as they're not in WEB-INF or
   META-INF root directories.

When you deploy a webapp (WAR file) to a server (e.g. Tomcat), a foo.html
file at the root of the WAR will be available at
http://server:port/context/foo.html, where "context" is the context path
your webapp is deployed to (in many cases, this is the name of your WAR
file, without the *.war extension; but you can deploy a webapp at the root
of a server, so you can have http://server:port/foo.html) This is highly
dependent on how you deploy your webapps. You seem to be using the tools
integrated into Eclipse, and I have no idea how they work and what they do,
so I can't help further.

Then you need to understand how to build a WAR file with Maven.
Using the standard layout, i.e. with a pom.xml containing only the strict
minimum (groupId, artifactId, version, packaging=war, and dependencies, but
nothing in <build>), here's how it works:

   - Java source code in src/main/java (this is
   ${project.build.sourceDirectory}) is compiled into your target/classes
   (this is ${project.build.outputDirectory}) by the maven-compiler-plugin
   - Resources in src/main/resources (this is the default set of
   ${project.build.resources}) are copied into target/classes by the
   maven-resources-plugin
   - Then the maven-war-plugin will take target/classes and put it into
   WEB-INF/classes, it will take all your dependencies (declared in
   <dependencies> in your pom.xml) into WEB-INF/lib (unless they are declared
   with <scope>provided</scope> or <scope>test</scope>;
   <scope>provided</scope> is generally used to declare the Servlet API
   dependency, as it shouldn't be packaged into the WAR file, given it'll be
   provided –hence the name of the scope– by the server), and finally will
   take the content of src/main/webapp (this is the default value for the
   plugin's warSourceDirectory) and put it at the root of the WAR.
   By default, there should be a src/main/webapp/WEB-INF/web.xml file, or
   the plugin will complain; unless you reconfigure the plugin to ignore it
   (what you did in your pom.xml).
   The plugin will first create an "exploded WAR" in
   target/${artifactId}-${version} (this is actually
   ${project.build.directory}/${project.build.finalName}; this means you can
   change the subfolder name by configuring <finalName> into <build> in your
   POM, something you have in your pom.xml) and then will "ZIP" it into
   target/${project.build.finalName}.war
   Note that you can also configure the plugin to JAR the target/classes
   into WEB-INF/lib instead of copying it into WEB-INF/classes; this will work
   the same when deployed to a server, so is mostly a matter of preferences.

Now you should know all there is to know to build your WAR file.

   - put your JSP files into src/main/webapp. The path relative to
   src/main/webapp will be the path relative to the webapp root URL (i.e.
   src/main/webapp/tutorRegister.jsp will be at
   http://localhost:8013/WebApp/tutorRegister.jsp)
   - put your bootstrap JS and CSS files somewhere into src/main/webapp
   too; make sure the relative links between your JSPs and the bootstrap files
   work.

But look at your WAR file (after invoking Maven's "package" goal) to know
if you did things right. Only then try to deploy your webapp to Tomcat
using Eclipse Java EE tools, and fix things in your Eclipse config, without
moving files around or changing your pom.xml (because you validated that
already and you know it's right).

On Tue, Nov 6, 2018 at 2:42 PM Karen Goh <[email protected]> wrote:

> Hi Thomas,
>
> I have not heard back from you so I am writing to you again.
>
> Basically, I still can't get the localhost to run the jsp page properly.
>
> So, what I did now is re-edit the web deployment assembly
>
> https://ibb.co/eJ93Cq
>
> Now, another problem appeared :
>
> The URL appeared to be like this which differs from what you have mentioned
>
> http://localhost:8013/WebApp/WEB-INF/tutorRegister.jsp
>
> I am really lost and can't get going with my project so I really hope you
> could point out how to make it right.
>
> Here's my latest attempt :
>
> https://ibb.co/g4atCq
>
> https://ibb.co/kppH5A
>
> I am so sorry to trouble you again but I really hope how should I make the
> my URL correct.  Do I move all the jsp to above image folder and just below
> WEB-INF ?
>
> Tks & regards,
> Karen
>
> --- On Sun, 11/4/18, Karen Goh <[email protected]> wrote:
>
> > From: Karen Goh <[email protected]>
> > Subject: Re: Need advice to put my bootstrap template in Maven archetype
> web app
> > To: "Thomas Broyer" <[email protected]>
> > Date: Sunday, November 4, 2018, 1:25 PM
> >
> > --------------------------------------------
> > On Sat, 11/3/18, Thomas Broyer <[email protected]>
> > wrote:
> >
> >  Subject: Re: Need advice to put my
> > bootstrap template in Maven archetype web app
> >  To: "Karen Goh" <[email protected]>
> >  Date: Saturday, November 3, 2018, 9:21
> > PM
> >
> >
> >
> >  On Sat, Nov
> >  3, 2018 at 1:38 PM Karen Goh <[email protected]>
> >  wrote:
> >
> >
> >
> > --------------------------------------------
> >
> >  On Fri, 11/2/18, Thomas Broyer <[email protected]>
> >  wrote:
> >
> >
> >
> >   Subject: Re: Need advice to put my
> > bootstrap template in
> >  Maven archetype web app
> >
> >   To: "Maven Users List" <[email protected]>,
> >  "Karen Goh" <[email protected]>
> >
> >   Date: Friday, November 2, 2018, 7:37
> > PM
> >
> >
> >
> >
> >
> >
> >
> >   On Thu, Nov
> >
> >   1, 2018 at 5:55 AM Karen Goh
> >
> >   <[email protected]>
> > wrote:
> >
> >
> >
> >
> >
> >
> >  --------------------------------------------
> >
> >
> >
> >   On Tue, 10/30/18, jieryn <[email protected]>
> >
> >   wrote:
> >
> >
> >
> >
> >
> >
> >
> >    Subject: Re: Need advice to put my
> > bootstrap template
> >  in
> >
> >   Maven archetype web app
> >
> >
> >
> >    To: "Maven Users List" <[email protected]>,
> >
> >   [email protected]
> >
> >
> >
> >    Date: Tuesday, October 30, 2018,
> > 8:31 PM
> >
> >
> >
> >
> >
> >
> >
> >    https://maven.apache.org/plugins/maven-war-plugin/usage.html
> >
> >
> >
> >
> >
> >
> >
> >   Hi Jieryn,
> >
> >
> >
> >
> >
> >
> >
> >   Just to clarify, so I have to place
> > the WebContent
> >  folder
> >
> >   which contents all my bootstrap css
> > etc under the
> >  resources
> >
> >   ?
> >
> >
> >
> >
> >
> >
> >
> >   I am confused cos the title is how
> > to WAR plug in where
> >  is
> >
> >   my question is more on the Maven
> > structure directory
> >  usage
> >
> >   for 3rd party bootstrap template.
> >
> >
> >
> >   In Maven, everything is done by
> >
> >   plugins, even the "standard" things.
> > Besides
> >  the
> >
> >   things that are part of the Project
> > Object Model
> >  (sources,
> >
> >   resources, output directory, test
> > sources, test
> >  resources,
> >
> >   test output directory), the
> > "standard layout"
> >  for
> >
> >   Maven projects are actually simply
> > the default
> >
> >   configurations for those plugins.If
> > you want to
> >
> >   build a WAR file for a web app,
> > you'll use
> >
> >
> >  <packaging>war</packaging> in your POM,
> >  which
> >
> >   will trigger the plugin bindings for
> > war packaging (
> https://maven.apache.org/ref/3.6.0/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging
> ).
> >
> >   The maven-war-plugin is responsible
> > for packaging the
> >  WAR
> >
> >   file, and by default will take the
> > "web
> >  resources"
> >
> >   from src/main/webapp.In you case,
> > you could
> >
> >   either reconfigure the
> > maven-war-plugin to use WebContent
> >  as
> >
> >   the warSourceDirectory, or move the
> > content of you
> >
> >   WebContent folder into
> > src/main/webapp (so you will
> >  have,
> >
> >   for example, a
> > src/main/webapp/WEB-INF/web.xml file
> >  instead
> >
> >   of WebContent/WEB-INF/web.xml)
> >
> >   See also
> https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
>
> >
> >
> >
> >  Hi Thomas,
> >
> >
> >
> >  Just to clarify, do you mean I have to
> > remove src/main/java
> >  from my pom which will point to the
> > source directory?
> >
> >  You don't need to configure
> >  src/main/java explicitly, it's the
> > default value for
> >  project.build.sourceDirectory.
> >  This is my new edited pom.
> >
> >
> >
> >
> > <packaging>war</packaging>
> >
> >
> > <version>0.0.1-SNAPSHOT</version>
> >
> >    <name>WebApp Maven
> > Webapp</name>
> >
> >    <url>http://maven.apache.org</url>
> >
> >    <properties>
> >
> >
> > <src.dir>src/main/java</src.dir> //
> >  DO i need to remove this ?  Will
> > maven compile without the
> >  java files ?
> >
> >  You can remove it,
> >  yes.Note that the line below redefines
> > the
> >  property, so this POM actually
> > configures
> >  project.build.sourceDirectory to
> >  src/main/webapp.
> >
> >
> > <src.dir>src/main/webapp</src.dir>
> >
> >      </properties>
> >
> >      <build>
> >
> >
> >
> > <sourceDirectory>${src.dir}</sourceDirectory>
> >
> >
> >
> >  <finalName>WebApp</finalName>
> >
> >      <plugins>
> >
> >        <plugin>
> >
> >
> >
> > <groupId>org.apache.maven.plugins</groupId>
> >
> >
> >
> > <artifactId>maven-compiler-plugin</artifactId>
> >
> >
> > <version>3.8.0</version>
> >
> >          <configuration>
> >
> >
> > <source>1.8</source>
> >
> >
> > <target>1.8</target>
> >
> >            </configuration>
> >
> >            </plugin>
> >
> >            <plugin>
> >
> >
> >
> > <artifactId>maven-war-plugin</artifactId>
> >
> >
> >
> >  <version>2.6</version>
> >
> >
> >
> >  <configuration>
> >
> >
> >
> >
> > <warSourceDirectory>WebContent</warSourceDirectory>
> >
> >  If you configure warSourceDirectory
> >  to be WebContent, then keep all your
> > web resources (JSPs,
> >  WEB-INF, etc.) into WebContent at the
> > root of your
> >  project.If you want to use the
> > "standard
> >  layout", then remove this
> >  line.
> >
> >
> >
> > <failOnMissingWebXml>false</failOnMissingWebXml>
> >
> >
> >
> >
> > </configuration>
> >
> >
> >        </plugin>
> >
> >      </plugins>
> >
> >
> >
> >
> >
> >  Can you please let me know the way I
> > put my Bootstrap files
> >  as per below is it correct?
> >
> >
> >
> >  https://ibb.co/eNbEdL
> >  Remove the "WebContent"
> >  level, and move webapp into src/main
> > (it's at src/webapp
> >  instead of src/main/webapp).If you
> > deploy your
> >  WAR into a server (Tomcat, whatever)
> > at http://localhost:8080/WebApp/,
> >  then a file at
> > src/main/webapp/index.jsp will be reachable
> >  at
> > http://localhost:8080/WebApp/index.jsp.
> >  Similarly, a file at
> >
> > src/main/webapp/WebContent/Bootstrap/Checkbox.js will be
> >  reachable at
> http://localhost:8080/WebApp/WebContent/Bootstrap/Checkbox.js
> >
> > Hi Thomas,
> >
> > I did what you said and move the
> > WEB-INF which contains the lib folder for image etc and the
> > jsps into src/main/webapp folder as per picture below.
> >
> > https://ibb.co/fYWi7f
> >
> > The folder which contains the
> > bootstraps in WebContent all all in white but the files like
> > bootstraps, css, fontawesome are still in side.  They
> > are now in src/main/webapp as well.
> >
> > However, when I ran the jsp file, the
> > url is
> http://localhost:8013/WebApp/WEB-INF/classes/WEB-INF/tutorRegister.jsp
> > and I think something is wrong here.
> >
> > Do you mean I should create a
> > src/webapp and then move everything - WEB-INF and its files
> > together with the bootstraps files like css, bootstrap all
> > onto src/webapp ?
> >
> > Hope to hear from you soon.
> >
> > Once again, thank you so much for your
> > help!  Really appreciated.
> >
> > Karen
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >    On
> >
> >
> >
> >    Sun, Oct 28, 2018 at 4:37 AM Karen
> > Goh
> >
> >   <[email protected]>
> >
> >
> >
> >    wrote:
> >
> >
> >
> >    >
> >
> >
> >
> >    > Hi,
> >
> >
> >
> >    >
> >
> >
> >
> >    > I have been
> >
> >
> >
> >    struggling for 2 days where to put
> > my bootstrap
> >
> >   template
> >
> >
> >
> >    that comes with pre-build template
> > which includes
> >  css,
> >
> >   fonts
> >
> >
> >
> >    etc. inside my maven web project
> > without success.
> >
> >
> >
> >    >
> >
> >
> >
> >    > The problem - jsp is
> >
> >
> >
> >    not rendering the bootstrap
> > layout.  It was
> >  rendering
> >
> >   ok
> >
> >
> >
> >    before I changed the project
> > structure which meets
> >  the
> >
> >   Maven
> >
> >
> >
> >    project standard structure.
> >
> >
> >
> >    >
> >
> >
> >
> >    > This is a 3rd party bootstrap
> > template.
> >
> >
> >
> >    >
> >
> >
> >
> >    > After reading up the
> >
> >
> >
> >    maven project structure, I have
> > tried to put it under
> >
> >
> >
> >    src/main/resources, tried under
> > src, tried moving
> >  around
> >
> >   all
> >
> >
> >
> >    parts of the directory but to no
> > avail....
> >
> >
> >
> >    >
> >
> >
> >
> >    > I also used the below
> >
> >
> >
> >    structure to move my WebContent
> > which included this
> >
> >   template
> >
> >
> >
> >    but it is still not working
> >
> >
> >
> >    >
> >
> >
> >
> >    >
> https://stackoverflow.com/questions/15529184/where-to-place-twitter-bootstrap-files-in-a-maven-project
> >
> >
> >
> >    >
> >
> >
> >
> >    > Here's my pom.xml
> >
> >
> >
> >    :
> >
> >
> >
> >    >
> >
> >
> >
> >    > https://ibb.co/fesnGV
> >
> >
> >
> >    >
> >
> >
> >
> >    > https://ibb.co/m7GQ3A
> >
> >
> >
> >    >
> >
> >
> >
> >    >
> >
> >
> >
> >    >
> >
> >
> >
> >    Here's where my bootstrap ended
> > now (still not
> >
> >   working)
> >
> >
> >
> >    - where I put the jsp files and
> > WebContent
> >  separately.
> >
> >
> >
> >    >
> >
> >
> >
> >    > https://ibb.co/fKArbV
> >
> >
> >
> >    >
> >
> >
> >
> >    > Please tell me where
> >
> >
> >
> >    should I put the bootstrap
> > template.
> >
> >
> >
> >    >
> >
> >
> >
> >    > Thank you & regards,
> >
> >
> >
> >    > Karen
> >
> >
> >
> >    >
> >
> >
> >
> >    >
> >
> >
> >
> >    >
> >
> >
> >
> >    >
> >
> >
> >
> >
> >   ---------------------------------------------------------------------
> >
> >
> >
> >    > To unsubscribe, e-mail: [email protected]
> >
> >
> >
> >    > For additional commands,
> > e-mail: [email protected]
> >
> >
> >
> >    >
> >
> >
> >
> >
> >
> >
> >
> >
> >   ---------------------------------------------------------------------
> >
> >
> >
> >    To unsubscribe, e-mail: [email protected]
> >
> >
> >
> >    For additional commands, e-mail:
> > [email protected]
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >  ---------------------------------------------------------------------
> >
> >
> >
> >   To unsubscribe, e-mail: [email protected]
> >
> >
> >
> >   For additional commands, e-mail: [email protected]
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
>

Reply via email to