3

I'm developing multiple java-ee web apps in Eclipse kepler & tomcat7 and now everything goes well. I get a specific app with http://localhost:8080/appname.

But can I do some settings to make this project with a blank name so that I can visit it by http://localhost:8080/

Tomcat 6: How to change the ROOT application may not work for the server integration way in Eclipse.

PS: Running on Windows XP with eclipse-jee-kepler-R-win32 and tomcat7

Community
  • 1
  • 1
Sam Su
  • 6,532
  • 8
  • 39
  • 80

3 Answers3

2

From experience, I would say that it cannot be done.

Since we cannot hide the URL.

Instead you can do,

  • Redirect the URL to application server via web server(Apache WebServer) so when you hit http://localhost:8080/ it will automatically redirect to the mapped URL say, http://localhost:8080/appname

    Cf : How to rewrite URL in Tomcat 6 and Is there a url rewriting engine for Tomcat/Java?

  • You can develop your application as a single page application and replace your content by updating div and span using AJAX. If you give http://localhost:8080/appname without changing or redirecting the URL we can do our tasks.

Community
  • 1
  • 1
ashokramcse
  • 2,841
  • 2
  • 19
  • 41
  • Your approach will work, but I don't believe it is necessary. Please see my solution to achieve this from Eclipse. – Michael Dec 29 '14 at 11:06
0

Creating (or renaming) a project called "ROOT" allowed me to do this within Eclipse.

When you initially "Run on Server" it will load the app using the long-form URL:

http://localhost:8080/ROOT

But if you navigate to:

http://localhost:8080/

You'll see it hits the same page.

One caveat is that in the Tomcat settings page in Eclipse, you'll need to ensure the Server Location is set to "Use workspace metadata". I initially had it set to "Use Tomcat installation" and calling the default http://localhost:8080/ URL would just load Tomcat's default page (presumably because a ROOT application already exists / takes precedence).

Update

I've found you can achieve the same result without changing your project name. Simply edit your Eclipse project's .settings/org.eclipse.wst.common.component file and change the context-root property to "ROOT" like so:

<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="YourProjectName">
        <wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
        <property name="java-output-path" value="/YourProjectName/build/classes"/>
        <property name="context-root" value="ROOT"/>
    </wb-module>
</project-modules>

Where "YourProjectName" is the name of your project, obviously. :)

Second Update

According to this answer on a related question you can actually change the content-root from the GUI in Eclipse but going to "Web Project Settings" in your project settings.

Community
  • 1
  • 1
Michael
  • 7,348
  • 10
  • 49
  • 86
0

well there are quite easy ways to do this:

  1. double click the Server Name (e.g Tomcat 7) in the Servers view;
  2. go the Modules tab;
  3. select the appname and click edit, then leave the path to blank
Sam Su
  • 6,532
  • 8
  • 39
  • 80