File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes IDEs, Version Control and other tools and the fly likes Changing Context Root Headache Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Changing Context Root Headache" Watch "Changing Context Root Headache" New topic
Author

Changing Context Root Headache

Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
Dear friends, I have a little problem to my Enterprise Project. I use NetBeans 6.5.


Can we change the web application context root after we created the project ? Currently the context root is named "/converter-war" and I want to change it to "/converter". How can I do that ? I already tried many ways but it didn't work. Please help me.

As an information, there is 4 projects :
converter
converter-app-client
converter-ejb
converter-war

This is the sample project in the Java EE tutorial, but I create the project and typing the source file instead of just opening the sample project.


Thanks


Jeffry Kristianto Yanuar (Java Instructor) SCJP 5.0 SCJA SCJD
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61447
    
  67

There shouldn't be any headaches. As long as you haven't hard-coded the context path within your application you should be able to deploy it to any path.

What specific problems are you having?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
Thanks for replying, I already found the solution. By changing the name of the web module project, the context root is changed too.

If the web module name is converter-war, then the context root is "/converter-war". I changed the web module name to converter, then the context root is "/converter"

Before changing web module, the entire projects are :
converter
converter-app-client
converter-ejb
converter-war
I accessed the web application by typing "www.localhost:8080/converter-war"

Now I changed the web module into :
converter
converter-app-client
converter-ejb
converter
Now I can access the web application by typing "www.localhost:8080/converter" which is what I want(I wanted to change the way I access the web application)


I can't believe it that the name of the web module in enterprise project in Netbeans determines the context root. Or maybe there is something I miss. Any idea ?


Jeffry Kristianto Yanuar (Java Instructor) SCJP 5.0 SCJA SCJD
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61447
    
  67

As this is a Netbeans issue, rather than a general servlet question, I've moved it to the IDEs forum.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5838
    
    7

What application server are you using? Most of the ones I have worked with use the WAR file name as the default context name. Many application servers provide some mechanism to assign a different context name to the application. This is really is not a NetBeans issue.


JBoss In Action
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
I use GlassFish V2 Application server. Any idea ? Maybe when I was changing the web application module name, the JAR was changed too.


Jeffry Kristianto Yanuar (Java Instructor) SCJP 5.0 SCJA SCJD
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5838
    
    7

The IDEs tend to name the WAR file using the project's name, so I can see how changing the project name could change the context.
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
Was the Netbeans developes did that on purpose ?

Jeffry Kristianto Yanuar (Java Instructor) SCJP 5.0 SCJA SCJD
 
Consider Paul's rocket mass heater.
 
subject: Changing Context Root Headache