aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Web application root context question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Web application root context question" Watch "Web application root context question" New topic
Author

Web application root context question

Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
What are the rules for allowable values in the context-root element of application.xml?
I typically use it the way I suspect 99% of developers use it - its just a single token that corresponds to the war name, e.g:
<module>
<web>
<web-uri>myapp.war</web-uri>
<context-root>myapp</context-root>
</web>
</module>
and I'd get to the app features via something like:
http://myserver:8080/myapp/...
I've run into a deployment-time situation where I need to have the servlet context correspond to a path, such as:
http://myserver:8080/foo/bar/myapp...
I've been pounding my head against WebLogic 7 trying stuff like:
<module>
<web>
<web-uri>myapp.war</web-uri>
<context-root>foo/bar/myapp</context-root>
</web>
</module>
and same as above, but with an initial "/":
<module>
<web>
<web-uri>myapp.war</web-uri>
<context-root>/foo/bar/myapp</context-root>
</web>
</module>
I've yet to have any luck. Is this something that should work? In other words, am I doing something allowable but my web container doesn't correctly implement it, or am I doing something I should even be attempting?


Reid - SCJP2 (April 2002)
Serena Zhou
Ranch Hand

Joined: Dec 13, 2003
Posts: 31
May I ask if you have got the answer for this? I am facing the same problem.
Thanks!
Ture Hefner
Greenhorn

Joined: Nov 14, 2004
Posts: 18
It works for me with the latest (WLS 8.1 SP3). Sorry, I don't have 7.0 installed anymore.

In the J2EE spec, it says "See the servlet spec for detailed requirements of
context root naming." In the servlet spec, I don't see much. I would probably not end it with /, from what I read.

This works fine for me in application.xml:

<module>
<web>
<web-uri>beer.war</web-uri>
<context-root>beer/ture</context-root>
</web>
</module>

I access it like this:
http://localhost:7001/beer/ture/form.html

In the end, this is probably something to take up with BEA support. The context-root in application.xml is part of the J2EE packaging, used to override the context-root in weblogic.xml (which is, of course, WLS specific), which is used to override simply using the uri minus the .war extension as the context-root.

http://e-docs.bea.com/wls/docs81/webapp/weblogic_xml.html#1040721

I don't think the SCWCD exam covers J2EE app (EAR) packaging. It just covers the web app (WAR) as far as I know, so this forum probably won't be the best place to get an answer.


Ture
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Web application root context question