You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by William Brogden <wb...@bga.com> on 2000/10/08 15:18:24 UTC

Re: Problem invoking 'Applet' from a servlet (passing parameters)


ann patil wrote:
> 
> Hi,
> 
> Directory Structure that I have on my side:
> 
> abc
> |
> main  (root)    in server.xml <context>
>     |
>     applet
>     1) Abc.java
>     2) Abc.class
> 
> Used the following code to invoke the applet from the servlet:
> 
> out.println ("<HTML> <TITLE> Loading applet... </TITLE>");
> out.println ("<applet codedebase="  "http://localhost:8080/main/applet/"
> + " code=Abc.class >");
> out.println ("<param name=" + "userid" + "value=" + '"' + "Sam" + '"' + ">
> </applet></html>");
> 
> Error after execution: 'error loading class file Abc.class' in the web
> browser.
> It searches for the class file in /main/servlet/  directory.
> 
> Can anybody please help me out ?
> 
> Am I missing something ? I need to pass parameters to my applet through
> the servlet else I could had used the Redirect method.
> 
> Is there a way out ?
> 
> Thanks
> 
> Ann.

Remember that the browser is going to request those .class files
the same way it requests images and other resources! NOT through 
your servlet but through the normal web server request.

You could set the codebase to a normal directory but that
still leaves a problem in loading images, etc.

I suggest putting a <base> tag in the <head> area of the HTML
page pointing to a normal web server directory.

-- 
WBB - wbrogden@bga.com  Chief Scientist, LANWrights, Inc.
Java Programmer Certification information and mock exam
at  http://www.lanw.com/java/javacert/