No ... i don't have any others jars ... and i didn't set classpath or other variables 

Thence i'm confused ...

I'm attaching sample for better recognition 


Anna 

########################### test.jsp ##############################

<%@ page language="java" %>
<%@ page import="java.util.*, java.io.*, java.net.*, java.text.*, java.lang.*, 
java.util.jar.*, headline.*" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
 <title>Untitled</title>
</head>

<body>
<%
            String szPath = "<removedpath>\\MyJsp\\WEB-INF\\plugins";

  FileClassLoader c = new FileClassLoader(szPath);
  c.load("Hmmm", true);
%>
 

</body>
</html>

############################ MyInter.java #########################

package headline;

public interface MyInter {
 public void Test();
}
########################### FileClassLoader #######################


package headline;

import java.io.*;

public class FileClassLoader extends ClassLoader {

 private String basePath;

 public FileClassLoader(String basePath) {
  this.basePath = basePath;
 }

 public Class load(String typeName, boolean resolveIt) throws ClassNotFoundException {

  Class result = findLoadedClass(typeName);

  if (result != null) {
   return result;
  }

  byte typeData[] = getTypeFromBasePath(typeName);
  if (typeData == null) {
   throw new ClassNotFoundException();
  }

  result = defineClass(typeName, typeData, 0,
          typeData.length);

  if (result == null) {
   throw new ClassFormatError();
  }

  if (resolveIt) {
   resolveClass(result);
  }

  return result;
 }

 private byte[] getTypeFromBasePath(String typeName) {

  FileInputStream fis;
  String fileName = basePath + File.separatorChar
          + typeName.replace('.', File.separatorChar)
          + ".class";

  try {
   fis = new FileInputStream(fileName);
  } catch (FileNotFoundException e) {
   return null;
  }

  BufferedInputStream bis =
          new BufferedInputStream(fis);
  ByteArrayOutputStream out =
          new ByteArrayOutputStream();

  try {
   int c = bis.read();
   while (c != -1) {
    out.write(c);
    c = bis.read();
   }
  } catch (IOException e) {
   return null;
  }
  return out.toByteArray();
 }
}
############################ Hmmm.java ############################

import headline.*;

public class Hmmm implements MyInter{
 public void Test(){

 }

}



######################## file listing ##########################
-- MyJsp
  |
   -- test.jsp 
  |
   -- WEB-INF
      |
       --  classes
      |  |
      |   -- headline
      |     |
      |      -- FileClassLoader.class
      |     |
      |      -- MyInter.class
      |   
       -- plugins 
         | 
          -- Hmmm.class

Reply via email to