简体   繁体   中英

Servlet-Applet communication

I have an applet successfully signed and deployed in my application.

I have a index.html which loads the applet correctly if I make a call like /myApp

However,if I try to forward to index.html from a servlet, I´m getting a ClassNotFoundException .

Here are the code that loads the applet. All these jars are in the WebContent folder.

index.html

<applet code="com.griaule.grFingerSample.FormMain"
  archive="fingerAssinado.jar,SignedGrFingerJavaAppletSampleAssinado.jar,postgresql-8.4-701.jdbc4Assinado.jar"
</applet>

What am I doing wrong?

Any relative paths in archive attribute of HTML <applet> element are relative to the current request URL (the one as the client see in browser's address bar), not to the physical server's disk file system location of the JSP file responsible for generating the HTML output, as many starters incorrectly think.

So, if you fix the relative paths in to be properly relative to the current request URL, then it should work fine. You can if necessary make use of ${pageContext.request.contextPath} to dynamically print the current context path.

<c:set var="root" value="${pageContext.request.contextPath}" />
<applet ... archive="${root}/fingerAssinado.jar, ..." />

This way you can make it relative to the domain root.

See also:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM