Eclipse & Tomcat: How to specify which folder is served from the project?
Asked Answered
U

5

8

I'm using Eclipse 3.4 and Tomcat 5.5 and I have a Dynamic Web Project set up. I can access it from http://127.0.0.1:8080/project/ but by default it serves files from WebContent folder. The real files, that I want to serve, can be found under folder named "share". This folder comes from CVS so I'd like to use it with its given name instead of renaming it. How can this be done?

Unsnap answered 14/10, 2008 at 18:23 Comment(0)
T
8

In the project folder, there should be a file under the .settings folder named org.eclipse.wst.common.component that contains an XML fragment like this:

<wb-module deploy-name="WebProjectName">
    <wb-resource deploy-path="/" source-path="/WebContent"/>
    <wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>

You should be able to change the source-path under wb-resource to your share folder. I'd make these changes with the Eclipse project closed to be safe.

This is a setting that you pick when you first create the Dynamic Web Project in Eclipse - I can't find how to change the value in an existing project thru Eclipse itself.

If you want the share folder to be mapped to a different path when deployed, such as /share/ in your webapp, you can probably just add another wb-resource element.

Tallboy answered 14/10, 2008 at 18:57 Comment(2)
Great. Why so simple/common task are sometimes so hard to do in Eclipse !Obannon
I would guess because Eclipse treats the whole "web project tools" as a plugin, so the ease-of-use and quality might not be up to other project standards.Tallboy
C
4

Can be done through Eclipse, no need to manually edit .settings files.

In Eclipse 3.6 (and possibly earlier releases),

  1. right click on your project
  2. click on properties
  3. Click on 'Deployment Assembly'
  4. Add... Folder -> Next
  5. Navigate to source folder
  6. Finish
Cassaba answered 13/4, 2011 at 9:9 Comment(1)
You additionally have to ensure that the Project Facet "Dynamic Web Module" is active.Topless
P
2

if you're running windows, use the junction utility from MS : http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx and map your share directory to the Webcontent folder. I've regularly done several of these mappings quite regularly.

Proteiform answered 14/10, 2008 at 18:37 Comment(1)
This solves his problem in quite a round-about way, and isn't exportable to anyone else working on his project from other machines. Should be possible to solve the problem within Eclipse and his project itself.Tallboy
C
0

On STS 2.5.1

  1. right click on your project
  2. click on properties
  3. Click on 'Java Build path'
  4. Click "Source" tab
  5. Navigate to default out put folder
  6. Browse and add your path
  7. Finish
Cadaverous answered 15/8, 2012 at 13:7 Comment(0)
A
0

you can specify location of webcontent in R-click on project > Properties > Deployment Assembly

This is what I did in mys STS, you can add or remove a location.

Achondroplasia answered 1/4, 2015 at 17:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.