This servlet below works with ServletExec (my development system). Since my
classes were part of a package I had to supply the fully qualified path name
e.g.
http://localhost/servlet/LoadIt?class=com.knightsofthenet.test.bkParent
rather than as http://localhost/servlet/LoadIt?class=bkParent.
The classes I used to test had to have their system classpath available to
the servlet JVM e.g. wrapper.classpath=path/to/solvers
>
> Your problem might be a fundamental misunderstanding of how
> classloaders
> work. I recommend you read Shiang Leng's and Bracha's paper on
> loaders, see http://java.sun.com/people/gbracha/classloaders.ps
>
Wish I could. Is there a tool to search for that enables viewing .ps files
on Win95?
Code follows
HTH
***********************************************************
Brett Knights 626-432-5767 work
[EMAIL PROTECTED] 626-355-1017 home
***********************************************************
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.knightsofthenet.test.*;
public class LoadIt extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("<HTML><HEAD><TITLE>Loading It up</TITLE></HEAD><BODY>");
String myClass = null;
try {
myClass = req.getParameter("class");
}
catch (Exception e){
myClass = null;
}
if (myClass == null){
out.println("Pass me something");
out.println("</BODY></HTML>");
}
else {
Class maybeClass;
try {
maybeClass = Class.forName(myClass);
bkParent theClass = null;
theClass = (bkParent)maybeClass.newInstance();
out.println("Class: " + theClass.toString());
out.println("</BODY></HTML>");
}
catch (ClassNotFoundException e ){
out.println(myClass + ": Class not found");
out.println("</BODY></HTML>");
}
catch (Exception e){ // more better exceptions available
out.println("couldn't cast, not a bkParent!");
out.println("</BODY></HTML>");
}
}
}
}
----------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
READ THE FAQ!!!! <http://java.apache.org/faq/>
Archives and Other: <http://java.apache.org/main/mail.html/>
Problems?: [EMAIL PROTECTED]