(In response to Noah Davis)

At 05:55 AM 11/21/2002, Yoav Shapira wrote:
>Basically, we develop all of our applications under contexts. Each one
a
>separate context. When they go live, they go to the default context so
>users
>don't have to request everything with "/context/blah". This means that
if

Don't do this.  Deploy them to their own contexts if possible.  This
will let you do much more later in terms of security, administration,
etc.  If you're really hung up on users not having /context in their
bookmarks, have some redirect files (just for the app entry points: the
things users would bookmark) in the root context.
Agreed.  If you can avoid sloshing all the apps together, it'd be best.  But...

>the application has links to "/<context>/anything.jsp" or
>"/<context>/servletpath" (instead of "anything.jsp" and "servletpath")
>they'll break. So I guess my real question is, what's the best way to
>design
>the application so these problems don't arise. Or is this just a
>configuration issue?

Use relative links.  For example, if this is your structure:
/myApp
  -- some html files here
  -- /jsp
  -- /images
  -- /WEB-INF
     -- web.xml
     -- lib
     -- classes

Keep all links relative.  No /myApp/jsp/someJsp, just ../jsp/someJsp.
It'll save you trouble ;)
This is definitely the generally accepted way to do things, but there are very real situations (such as yours, it seems) where, for one reason or another, you've got your applications aware of and talking to eachother. If you've got a complex system where a single jsp may make a call to 3 different servers or apps -- granted, this situation should not be intentionally designed as such -- I've found that relative links complicate life more than help. Because we have to support a multitude of deployment configurations, we decided long ago to dynamically generate each link based on some configuration files. In the jsp, it looks something like:

<% // For dynamic content
String urlPrepend = MyAppConfig.getURLPrepend();
// For static content
String webUrlPrepend = MyAppConfig.getWebURLPrepend();
%>

<form action="<%=urlPrepend%>/historyQuery.jsp">

Depending on configuration, the generated link could look like:

"/myWebApp/historyQuery.jsp"
"http://somehost.com/proxy/myWebApp/historyQuery.jsp";
"http://somehost.com:8080/myWebApp/historyQuery.jsp";

... and so on. A little simplified for, but that's the basic idea. Because I'm also responsible for deployment of our apps, I want as many options as possible, and something like this gives it to me.

Anyways, if you do this, you can modify all your urls with a simple flick of the configuration switch and make all your references independent of your context name, host port, proxy configuration, etc. Sounds like you could benefit from that as well.

justin


--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to