不用 直接调用getInitParameter(".."); 如public class BulletinBoard extends HttpServlet { private String filePath; //stores root path for bulletin files private Properties propTopics; //stores bulletin board topics /** * init() method is called when the servlet is first loaded. It * reads the directory where the bulletin files are stored from * an initialization parameter. */ public void init() throws ServletException { FileInputStream fileTopics = null;
//open input stream to topics.properties file //fileTopics = new FileInputStream("c:\\topics.properties"); filePath=getInitParameter("FilePath");
直接调用getInitParameter("..");
如public class BulletinBoard extends HttpServlet
{
private String filePath; //stores root path for bulletin files
private Properties propTopics; //stores bulletin board topics
/**
* init() method is called when the servlet is first loaded. It
* reads the directory where the bulletin files are stored from
* an initialization parameter.
*/
public void init() throws ServletException
{
FileInputStream fileTopics = null;
//open input stream to topics.properties file
//fileTopics = new FileInputStream("c:\\topics.properties");
filePath=getInitParameter("FilePath");