Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Tomcat: using webapp context to override default URL

Reply
Thread Tools

Tomcat: using webapp context to override default URL

 
 
sugnaboris@gmail.com
Guest
Posts: n/a
 
      03-05-2008
Hope someone can help with a config problem I'm having. Many thanks in
advance for at least taking a look.

I'm building a WAR using Netbeans 5.5.1. The WAR takes its name from
the project root directory, so I end up with MyProjectRoot.war. I drop
this into the webapps folder under Tomcat 5.5, and it gets expanded
out into a directory of its own called MyProjectRoot. This has a META-
INF directory, containing a context.xml file, which has the following
contents:

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/MyURL"/>

in other words, I want to be able to access the webapp using:

http://<server>:8080/MyURL

However, I can only access the webapp at:

http://<server>:8080/MyProjectRoot

I've noticed that a new file has been generated in the directory:

Tomcat 5.5\conf\Catalina\localhost

This is called MyProjectRoot.xml, and has the following contents:

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/MyURL"/>

At the moment, I can work around by renaming the WAR prior to
deployment; but this should ideally be configurable.

Can anyone advise on how I can use the webapp configuration to force
the URL that I want? I thought the context.xml contents would do that:
it seems to work OK with the NetBeans bundled Tomcat during
development - although the webapp then lives outside the Tomcat
hierarchy.

Thanks again to all who read this far, and especially to anyone who
can advise on how to achieve this!

Ron
 
Reply With Quote
 
 
 
 
Marcelo Morales
Guest
Posts: n/a
 
      03-05-2008
The trick is to put just a .xml file under conf/Catalina/localhost/

Try something like:

<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="/export/zfs/marcelo/mypath/MyProjectRoot" path="/
MyUrl"/>

and put the exploded app under /export/zfs/marcelo/mypath/
MyProjectRoot/

See
http://tomcat.apache.org/tomcat-6.0-...yer-howto.html

Hope it helps
 
Reply With Quote
 
 
 
 
sugnaboris@gmail.com
Guest
Posts: n/a
 
      03-06-2008
On 5 Mar, 17:41, Marcelo Morales <(E-Mail Removed)>
wrote:
> The trick is to put just a .xml file under conf/Catalina/localhost/
>
> Try something like:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Context docBase="/export/zfs/marcelo/mypath/MyProjectRoot" path="/
> MyUrl"/>
>
> and put the exploded app under /export/zfs/marcelo/mypath/
> MyProjectRoot/
>
> Seehttp://tomcat.apache.org/tomcat-6.0-doc/deployer-howto.html


Thanks, Marcelo - I'll give it a go and let you know what happens. I
see that's for 6.0, but maybe it's the same deal with 5.5. I already
have an automatically-generated file in that location, named after the
webapp - is the filename important?

> Hope it helps


Don't we all!
 
Reply With Quote
 
Marcelo Morales
Guest
Posts: n/a
 
      03-06-2008
On Mar 6, 4:32 am, (E-Mail Removed) wrote:
> On 5 Mar, 17:41, Marcelo Morales <(E-Mail Removed)>
> wrote:
>
> > The trick is to put just a .xml file under conf/Catalina/localhost/

>
> > Try something like:

>
> > <?xml version="1.0" encoding="UTF-8"?>
> > <Context docBase="/export/zfs/marcelo/mypath/MyProjectRoot" path="/
> > MyUrl"/>

>
> > and put the exploded app under /export/zfs/marcelo/mypath/
> > MyProjectRoot/

>
> > Seehttp://tomcat.apache.org/tomcat-6.0-doc/deployer-howto.html

>
> Thanks, Marcelo - I'll give it a go and let you know what happens. I
> see that's for 6.0, but maybe it's the same deal with 5.5. I already
> have an automatically-generated file in that location, named after the
> webapp - is the filename important?
>
> > Hope it helps

>
> Don't we all!


AFAICT, the filename is important. It shouldn't be, though. I think I
remember reading about it on the page which link I already sent you.

Have fun finding out

Marcelo Morales
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Where to start with a webapp that is not really a webapp Andrew Java 7 06-28-2009 08:42 PM
How do I find the webapp name from within a context without changingweb.xml? christopher@dailycrossword.com Java 1 04-22-2008 04:07 PM
Override default base URL reference hrh1818 HTML 1 02-14-2008 04:50 AM
[AxWindowsMediaPlayer] Override Context Menu and Mouse Hover blue-einstein ASP .Net Building Controls 0 02-23-2006 05:36 AM
What should I do webapp or webservice + webapp? jhooper71@yahoo.com ASP .Net 6 02-10-2006 02:07 PM



Advertisments