Noah --
I don't really see how doing
<form action="/<context>/doThis" method="post">
makes your app dependent on your context ... it makes your app dependent on the _name_ of your context, but not anything else about your context. If you move your app around to other appservers, you'll always have to define a name in some proprietary way. If you're concerned about this (ie want to be able to dynamically create the application name), then why not just make this a configurable parameter and do something such as this in each of your jsps:
<% String urlPrepend = MyConfig.getAppNamePrepend();
%>
...
<form action="<%=urlPrepend%>/doThis" method="post">
(or some variation thereof). There are many ways to implement a process for doing this depending on what sort of Tomcat/J2EE "features" you're using and your deployment requirements. Be sure you really need application _name_ independence, though ... most apps don't need this.
justin
At 11:58 PM 11/16/2002, you wrote:
Any other thoughts on this? Someone suggested using Struts . . but short of instituting a framework . .----- Original Message ----- From: "Noah Davis" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, November 12, 2002 8:18 PM Subject: proper use of servlet contexts I have a question regarding the proper way to use servlet contexts. The way I've been using them I always seem to bump into one problem or another which affects the flexibility of using servlets or affects the portability of my application. Here's my problem: I developed several servlets and defined them in the web.xml file. Then I referenced them in a form as such: <form action="/<context>/doThis" method="post"> Now I've made my application dependent on my servlet context. Ok, so I decided that instead of referencing my servlets in a root (context) relative way I would reference them in a relative way from the page i'm on: <form action="doThis" method="post"> I would then map the servlet in a way that parallels my physical directory structure. If the form tag above was on a page "/help/finance/index.jsp", I would have to map the above servlet as "/help/finance/doThis", in order for it to resolve correctly. Ok, great. Now I have a way to refer to servlets that doesn't affect the portability of my application. But it's seems like this isn't a great solution either. What if I use this servlet in multiple places? Now I have to go back and add new mappings in each place to make sure that a relative call to this servlet works in these cases as well. Now I'm thinking that possibly the best solution is to prepend the servlet context for each form action call: <form action="<%=pageContext.getServletContext()%>doThis" method="post"> But this seems like a round about way to go for something so simple. Am I missing something here? A second issue is that if your servlet does a forward using the request dispatcher AND your servlet url mapping does not reflect your directory structure, all the image paths and links and such could get screwed. There is a workaround using the HTML Base tag, but this isn't an option in my particular situation. Thoughts on this? Thanks in advance. Noah -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>