On Fri, 27 Oct 2000, Heakyung Park wrote:

> Yes, I did that. I set the html file under webpages directory
> setting codebase to "servlet/" where I put my applet class file in
> it. But still it doesn't load the applet. I am continously getting
> "applet couldn't be loaded". It does load all other html things
> except the applet. For my guess, it finds the applet, but doesn't
> know how to load or I am missing something in my applet. I can
> clearly view the applet by appletviewer.

You don't seem to be listening to/understanding my
comments/suggestions.  I will try once more to explain.

I am 99% sure the problem is that the applet code is not being found
(don't get hung up on any distinction between "find" and "load" at
this point).  That is, where it is looking, where you are indicating
the applet code is, is not actually where it is.  (You "indicate"
where it is by where the HTML file is, modified by the CODEBASE
attribute.)

Most likely, "servlet/" is not a real directory, it is a virtual
directory that the servlet container knows about -- it is where it
goes to look for servlets.

When a request comes in for something like:

http://www.domain.com/servlet/Something/or/other

the "servlet/" part of the URL tells the web server to pass control to
the servlet container, which then uses the "/Something/or/other" part
of the URL to know which servlet to call.  Neither the servlet
container nor the web server will be able to properly handle applet
code requested via a URL containing "servlet/"; similar for applet
code placed in the same directory as the servlets (this is a bit of a
simplification, but should be sufficient/accurate here).

My previous suggestion was to take the servlet totally out of the
loop, just to show that you can get the applet to run, and to improve
your understanding of how all the pieces fit together.  You can do
this by putting the HTML file and the applet code in the root document
directory of your web server.  For that, you shouldn't need a CODEBASE
attribute.  Try this, and see if you can get it to work.

Also, have you checked your servlet container and/or web server logs
to see if there are any relevant messages there?  I strongly suspect
there are some things in there that would be very helpful in isolating
the problem.

This is most certainly a case where a sniffer or similar would come in
handy, so you could see exactly what was being requested and what the
response is.


> On Fri, 27 Oct 2000, Milt Epstein wrote:
>
> > On Fri, 27 Oct 2000, Heakyung Park wrote:
> >
> > > Hello! I have tried several approaches suggested. However, I am
> > > still having same problem. My problem is that I placed applet and
> > > html in the same directory, and when I call the html file (that has
> > > <applet> tags) from other servlet. All other materials is displayed
> > > properly, except the applet, and I am getting "applet cannot be
> > > loaded!" Any suggestion! Thanks in advance. My applet doesn't
> > > communicate with any other resources at all for now, it just
> > > displays a chart.
> >
> > Why don't you try getting it working without the servlet first -- that
> > should help get you going, and eliminate some variables as being the
> > cause of the problems.  That is, set up a static HTML file, in a
> > regular, non-servlet directory, with the APPLET tags, and get that
> > working.  You can probably do it with the applet class files in the
> > same directory as the HTML file, or in separate directory, using
> > appropriate settings for the CODEBASE attribute.
> >
> >
> > > On Tue, 24 Oct 2000, Heakyung Park wrote:
> > >
> > > > I stored the applet in the same directory as the servlet is located. My
> > > > problem is not finding the applet to be loaded, it is that "the applet
> > > > cannot be loaded." I tried the code base approach, if the browser doesn't
> > > > find the applet, the message says "the applet cannot be found." I hope I
> > > > didn't misunderstand you. Thanks.
> > > >
> > > >
> > > > On Tue, 24 Oct 2000, Milt Epstein wrote:
> > > >
> > > > > On Tue, 24 Oct 2000, Heakyung Park wrote:
> > > > >
> > > > > > So you mean the reason I am having the problem is due to my code? No other
> > > > > > possible reason?
> > > > > >
> > > > > > The following is the servlet code to display java applet;
> > > > > > import java.io.*;
> > > > > > import javax.servlet.*;
> > > > > > public class gan extends GenericServlet {
> > > > > >         public void service (ServletRequest request, ServletResponse
> > > > > > response) throws ServletException, IOException {
> > > > > > response.setContentType("text/html");
> > > > > > PrintWriter pw = response.getWriter();
> > > > > > pw.println("<html><head><title>Gentt Chart</title></head><body>");
> > > > > > pw.println("<h1>Project Schedule in Gantt Chart</h1>");
> > > > > > pw.println("<applet code=\"gantt\" width=500 height=500></applet>");
> > > > > > pw.println("</body></html>");
> > > > > > pw.close();
> > > > > > }
> > > > > > }
> > > > > [ ... ]
> > > > >
> > > > > I suspect the problem is that the browser cannot find the applet code
> > > > > to (down)load.  The way you have it above, the applet code is expected
> > > > > to be in the same "directory" as the html page, but that html was
> > > > > generated by a servlet, so it's in the servlet virtual directory.  I
> > > > > think you need to specify a directory via the CODEBASE attribute on
> > > > > the APPLET tag that will tell the browser where to find the applet
> > > > > code.  (The exact value of which depends on where the applet code is.)
> > > > >

Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
[EMAIL PROTECTED]

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to