public class UserDao {
	
	public void update() throws IOException{ 
		InputStream in = UserDao.class.getClassLoader().getResourceAsStream("db.properties");
		
		Properties props = new Properties();//map保存
		props.load(in);
		
		System.out.println(props.getProperty("url"));
	}
}

然后在servlet中

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		UserDao dao = new UserDao();
		dao.update();
	}

运行servlet就能得到输出