Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Web application root context question

 
Reid M. Pinchback
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Serena Zhou
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May I ask if you have got the answer for this? I am facing the same problem.
Thanks!
 
Ture Hefner
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic