Question about upgrading Tomcat

2002-07-19 Thread Eric Leung

Hi All,

This is my first question post to this mailing list.
I'm trying to upgrade the application written for tomcat 3.1.x to 3.2.4 or
3.3.1
But I found that there are codes written specifically for v3.1 and they are
deprecated.

The following code segment is from a very first servlet called for the web
site.
.
.
.

import javax.servlet.GenericServlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.ServletException;

import org.apache.tomcat.core.Context;
import org.apache.tomcat.core.ServletContextFacade;


public class InitServlet extends GenericServlet {

private static Hashtable obj_table;
private static String CONFIG_NAME = xxx.properties;


public InitServlet() {
super();
}

public void init(ServletConfig conf) throws ServletException {
super.init(conf);

obj_table = new Hashtable();

// Get the context of this servlet
Context context = ((ServletContextFacade) conf.getServletContext()).
getRealContext();

obj_table.put(context.getClass().getName(), context);

String conf_filename = context.getContextManager().getTomcatHome() +

File.separator + conf + File.separator + CONFIG_NAME;

if (! new File(conf_filename).exists()) {
// Configuration file doesn't exist; tell user
log(Configuration file:  + conf_filename +  does not
exist);
log(Please make sure file exist for the xxx application);
System.err.println(Configuration file:  + conf_filename +
 does not exist);
return;
}

.
.
.
}

.
.
.

Since the org.apache.tomcat.core.Context and
org.apache.tomcat.core.ServletContextFacade have been deprecated,
do you know how should I modify the servlet to make it work in 3.2 or 3.3?

Any suggestion, advice, comment, or pointers are greatly appreciated.
Thanks,
Eric Leung




Re: Question about upgrading Tomcat

2002-07-19 Thread Henner Zeller


Hi,
   Context context = ((ServletContextFacade) conf.getServletContext()).
   getRealContext();
..
 
conf.getServletContext().getRealPath(/my/path/to/the/config/file.xyz);

resolves names relative to your context. This is part of the servlet spec.

ciao,
 -hen


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