• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Eclipse configuration

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eclipse 3.3.1.1 / Tomcat 5.5.25
I am configuring an application that must run from the root directory of a virtual host. The application currently is in production and runs just fine but we would like to move development to Eclipse.

Creating a Dynamic Web Project in Eclipse we end up with the application running in a context and a URL to the application like:
http://localhost:8080/myApp/
The problem is that almost all of the resources have been given an absolute reference (e.g. "/resource.ext") not to mention when the application runs it runs from the root as
http://localhost:8080/

How is it possible for us to configure Eclipse to do this?

Thanks from a bunch of Eclipse noobs.
 
Bartender
Posts: 21004
128
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, the best thing to do is make the application context-independent. That way you can install it under ANY context - root or not - and it will still work OK. That not only makes development easier, it also adds flexibility in deployment. For example, when you need clustering or intend to front the J2EE app with another server (possibly for load balancing).

The biggest problem about writing most apps comes in making the JSP's context-independent, unless you're also generating full URLs from program code (which I don't recommend).

Use relative URLs where possible. Where it's not (for example, to make absolute references to a style or image directory, code like following scriptlet:


When using a state-of-the-art platform, the following EL expression also works:


However EL is not supported as universally as scriptlets. The Login pages when using form-based security, for example, are presented by a lightweight framework that can only handle the scriptlet version.
 
Nicky Mane
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand your arguments for making the application context-independent. The problem is the application is already written using absolute references (e.g. /login.do or /master.css)

Are you saying that there is NO way to configure eclipse so the application is run from root (without rewriting it?)

Thanks for any help.
 
Tim Holloway
Bartender
Posts: 21004
128
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The mere existence of a "login.do" - absolute or relative - means I'll cheerfully give steep odds that you've got bigger problems than development environments. But that's a whole different rant.

Eclipse itself doesn't come with a web application container. When you "run webapps in Eclipse", what you're really doing is interacting with a plugin that supplies (or connects to) a web application server.

That web application server is frequently Tomcat, either by itself or embedded in a more complete container such as JBoss.

In that case, one of the following 2 solutions might help.

1. Setup a context xml in the TOMCAT_HOME/conf/Catalina/localhost directory whose application context is root. If you have a Tomcat item on the Window/Preferences menu, this will be the directory listed as the "contexts" directory.

2. Add a META-INF/context.xml file to your WAR. This is where Tomcat will look if you didn't do the above.

In either case, the context will look something like this:



Ignore the Realm definition - you're not using one.

The root context on Tomcat is a little unusual compared to subsidiary contexts. You may have to do a few other things to ensure that none of the standard root-context functions get in the way, but presumably someone knew how to do that for the production server.
 
Nicky Mane
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:In that case, one of the following 2 solutions might help.

1. Setup a context xml in the TOMCAT_HOME/conf/Catalina/localhost directory whose application context is root. If you have a Tomcat item on the Window/Preferences menu, this will be the directory listed as the "contexts" directory.

2. Add a META-INF/context.xml file to your WAR. This is where Tomcat will look if you didn't do the above.


Neither one of these works so I assume you were just guessing. We had already tried these configs. as they are standard setup with Tomcat 5.5.x. We have since moved to Ganymede/Tomcat 6.0.x and were able to setup the app to run at domain root. Problem solved.

Tim Holloway wrote:The mere existence of a "login.do" - absolute or relative - means I'll cheerfully give steep odds that you've got bigger problems than development environments. But that's a whole different rant.


Could you elaborate?
 
Let nothing stop you! Not even this tiny ad:
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!