Rafael Roque
Rafael Roque

Reputation: 377

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?

Upvotes: 0

Views: 211

Answers (1)

BalusC
BalusC

Reputation: 1108722

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:

Upvotes: 1

Related Questions