Mark Brown wrote:
>
> I am currently stumped by a problem using the plugin.  I've searched the web,
> the user forums and at least two books for any reference to this type of problem
> with no luck.
>
> I have a jsp page which uses the plugin (version 1.2.2_007) which is to load an
> applet.  The applet, in its init() method, will establish a connection to a
> servlet using http tunneling and an ObjectOutputStream to pass a reqest object
> for some database information.  The servlet will execute the jdbc command,
> format the result set into some vectors and store all of the information into a
> response object and send the information back to the applet which is waiting for
> the response using an ObjectInputStream.  The problem is, that when the jsp page
> attempts to load the applet, the following error occurs:
> [...]
> load: class WEB-INF.classes.EditTablesApplet not found.
> java.lang.ClassNotFoundException: java.io.FileNotFoundException:
> http://localhost/examples/WEB-INF/classes/EditTablesApplet.class
> [...]
> I'm running JDK1.3 and Tomcat 3.2.1 on an NT4.0 machine.  I have administrator
> rights on this machine.
> The Tomcat directory structure looks like:
> Location of the jsp page:
> F:\jakarta-tomcat\webapps\examples\jsp\EditTables\EditTablesApplet.jsp
>
> Location of applet class file:
> F:\jakarta-tomcat\webapps\examples\WEB-INF\classes\EditTablesApplet.class
>
> Location of servlet class file:
> F:\jakarta-tomcat\webapps\examples\WEB-INF\classes\servlet\EditTablesServlet.class
>
> The code fragment from my jsp file for the plugin follows:
>
> <jsp:plugin type="applet" code="WEB-INF.classes.EditTablesApplet"
> codebase="/../examples" jreversion="1.3" width="500" height="500" >
>     <jsp:fallback>
>         Plugin tag OBJECT or EMBED not supported by browser.
>     </jsp:fallback>
> </jsp:plugin>
>
> I've tried variations of the codebase directory and the code property.  I've
> tried it with and without the .class extension in the code property.
> So far, I've had no luck in getting the applet to load.
> Has anyone run into a similar problem or have a suggestion for me?  Any help
> would be greatly appreciated.
>
> Sorry for the length of the post,
> Mark

There are two main problems here:
1) Files under WEB-INF can not be accessed through HTTP requests. The WEB-INF
   directory is intended for resources used by the server application only,
   such as class files for beans you use in your JSP pages. So you must place
   the applet classes in a directory that's "public" (can be accessed through
   HTTP), for instance in a subdirectory named "classes" in the directory
   where you have the JSP page (<...>jsp\EditTables in your case). The
"codebase"
   attribute must contain the path to this directory, i.e. codebase="classes"
   in this case.
2) The directory structure for the directory where you store the class
   files must mirror the package structure. For instance, if your class
   belongs to a package named com.foo, you need to place it in a subdirectory
   to your "classes" directory named "com\foo". The "code" attribute must
   contain the complete class name, including the package name. In your
   case, it doesn't look like you use a package name (you seem to incorrectly
   use the directory name as a package name).

So, after you have moved the class files to a "classes" subdirectory in the
directory where you have the JSP page, try something like this:

  <jsp:plugin type="applet" code="EditTablesApplet"
    codebase="classes" jreversion="1.3" width="500" height="500" >
    <jsp:fallback>
      Plugin tag OBJECT or EMBED not supported by browser.
    </jsp:fallback>
  </jsp:plugin>

I talk about how to use the <jsp:plugin> action, and describe how to do most of
things people ask about on this list actually, in my JSP book:

  <http://TheJSPBook.com/>

Read it. I recommend it :-)

Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com
Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to