Apache JServ- java.lang.ClassNotFoundException: Applet1

I need to have my HttpServlet host an applet (see code below).

The question is where do I put the applet class so that it can be downloaded to the browser?

I have tried htdocs in the Apache webserver directory. I have tried the servlets directory where the servlet is located. All I get is the error java.lang.ClassNotFoundException: Applet1.



The following is my servlet code.

import java.io.*;

import javax.servlet.*;
import javax.servlet.http.*;

public class TestServlet extends HttpServlet
{
  public void doGet(HttpServletRequest request,
                    HttpServletResponse response)
    throws ServletException, IOException
  {
    PrintWriter out;

    response.setContentType("text/html");
    out = response.getWriter();

    out.println("<html>");
    out.println("<head><title>This is a test</title></head>");
    out.println("<body>");
    out.println("<h1>Apache works</h1>");
    out.println("<applet");
    out.println("code=Applet1.class");
    out.println("width=800");
    out.println("height=600>");
    out.println("</applet>");
    out.println("</body></html>");
  }
}
jmayfieldAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

inksystemsCommented:
If you put your applet in default root directory of web server ($APACHE_HOME/htdocs) you should change the line

out.println("code=Applet1.class");

in your code to

out.println("code=/Applet1.class");

Or put .class files in some directory in web server tree, for example $APACHE_HOME/htdocs/applets and change that line to

out.println"code=/applets/Applet1.class");

0
mbormannCommented:
so many points for a simple questio ?
:(
0
jmayfieldAuthor Commented:
By adding a / in front of Applet1.class, I now get the following:

Error loading class: .Applet1
java.lang.ClassFormatError: Name mismatch: /Applet1 != Applet1
java.lang.ClassNotFoundException: .Applet1

inksystems, thanks for trying. Have you tried what I'm trying on your own. Basically, a servlet that spawns an applet. I am running the server on NT.

As a note to mbormann, by offering so many points, I normally get quick and accurate responses like the one above.
0
inksystemsCommented:
Sorry,
add the following line:

out.println("CODEBASE=/");

or

out.println("CODEBASE=/applets");

within APPLET tag.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jmayfieldAuthor Commented:
Much thanks. Very well done. Thanks for being prompt.

<applet CODEBASE=/ code=Applet1.class>
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.