i am calling applet jar file like this

out.println("<APPLET code = com.Sample.class " +
		"codebase = /WebContent/WEB-INF/" +
		"archive = SamplePassword_signed.jar " +
		"WIDTH = 200" +
		"HEIGHT = 350>" +
		"</APPLET>");

but it gives me a error that class path :
class com.Sample.class not found.
i have stored applet jar in web-inf folder . i am using eclipse as IDE please help me to get out put

Dani AI

Generated

Short refresher and practical next steps (builds on and ):

The core problem was that the browser must fetch the applet JAR over HTTP from a location it can reach — putting the JAR under WEB‑INF makes it invisible to browsers because WEB‑INF is a server‑side, non‑public area. Move the signed JAR into a public folder inside your webapp (for example /yourContext/applets/) and reference that URL from the page your servlet emits. (docs.oracle.com)

To pass data from your servlet to the applet, emit the normal applet tag (or object/embed) from the servlet and include <param> elements with the values you need. The applet reads them with getParameter("name"). Example (the servlet writes this HTML into the response):

<applet archive="/yourApp/applets/SamplePassword_signed.jar"
        code="com.example.Sample" width="200" height="350">
  <param name="userId" value="12345">
  <param name="mode" value="demo">
</applet>

Inside the applet call getParameter("userId"). (docs.oracle.com)

Two common ways for the applet to call a JSP on the server:

  • Ask the browser to open the JSP (user navigates there) with AppletContext.showDocument(new URL(getCodeBase(), "target.jsp")). (docs.oracle.com)
  • Have the applet perform an HTTP call (URL/URLConnection) back to a servlet/JSP endpoint and read the response (GET or POST). Note: unsigned applets are normally restricted to connecting only to the host they were loaded from; if you need broader privileges you must sign the JAR and declare permissions. (web.mit.edu)

Important caution: Java browser applets are effectively obsolete — modern browsers dropped NPAPI/plugin support and Oracle removed the deployment stack in recent JDKs — so prefer migrating the UI to HTML5/JavaScript or use an alternative launcher (for JNLP apps, OpenWebStart). Test quickly by pasting the JAR URL into a browser to confirm it’s reachable, check server logs for 404s, and use the Java Console for runtime exceptions. (developer.mozilla.org)

Recommended Answers

All 5 Replies

Sharath,
When you specify "codebase = /WebContent/WEB-INF/" the browser will serach for the Class file of your Applet in the "/WebContent/WEB-INF/" in the directory in which it is running on the client machine where your servlet output is being displayed, it does not look for the class file on the server where your servlet is deployed.

For the browser to look for your applet class on the server, you need a URL of the type "" to your "codebase".

Also the class file of your applet will need to be moved out from the WEB-INF directory and into another folder from where the browser can access it via the "" URL pattern

Also this should also prove somewhat useful.

Also please use code tags from the next time whenever you post any code.

And please be careful in your problem description.
You're not calling an applet from a servlet, you're including an applet tag in the output generated by a servlet.

thank u very much ... i wll try with that

Sharath,
When you specify "codebase = /WebContent/WEB-INF/" the browser will serach for the Class file of your Applet in the "/WebContent/WEB-INF/" in the directory in which it is running on the client machine where your servlet output is being displayed, it does not look for the class file on the server where your servlet is deployed.

For the browser to look for your applet class on the server, you need a URL of the type "" to your "codebase".

Also the class file of your applet will need to be moved out from the WEB-INF directory and into another folder from where the browser can access it via the "" URL pattern

Also this should also prove somewhat useful.

Also please use code tags from the next time whenever you post any code.

thanks its working now

hi i have a problem i have to call applet from servlet and then from applet i have to call jsp when i click a button in applet.. please give a sample code for this and also how to send parameters from servlets to applet and applet to jsp

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.