Please help to come to from this problem:
i had written a sample code to display Hello and imported as jar files then created new dynamic web project and using a hello.jsp page i am calling the applet class but its not display the applect please give me the solutions:
the code is as follows:

hello.jsp:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
Welcome to Applet
<br></br>....................................
<applet codebase="/WEB-INF" archive="SampleApplet.jar" code="com.Hello.class" width="400" height="400" align="MIDDLE" alt="Java needed to display this Applet.">
<param name="flavour" value="strawberry">
........................................................
</applet>
</body>
</html>

and
SampleApplet.jar fle stored as follows:

SampleWebApplication:-
- WebContent:-
- WEB-INF:-
-hello.jsp
-SampleApplet.jar
-web.xml

SampleApplet.jar Contains the Class like :

com :
Hello.class

Dani AI

Generated

Most likely cause: the browser cannot fetch the JAR because the applet's codebase points at WEB-INF (a container-private directory). Resources under WEB-INF are not served directly to clients, so any archive or class placed there will never be downloaded by the browser. 's note about running in a real browser is correct, but the immediate problem is the deployment path rather than Eclipse vs. browser. (stackoverflow.com)

Fixes to apply (deploy + HTML/JSP changes):

  • Move SampleApplet.jar out of WEB-INF into a public folder (for example WebContent/applets or the same folder as hello.jsp). The archive must be addressable by HTTP from the page that embeds the applet.
  • Verify the JAR contains the package path (com/Hello.class) with the jar tool: jar tf SampleApplet.jar and confirm the entry com/Hello.class exists.
  • Use an applet tag whose archive and code match the public path and package name. Example (place this in the served HTML/JSP page, not using /WEB-INF as codebase):
<applet archive="applets/SampleApplet.jar" code="com.Hello" width="400" height="400">
  <param name="flavour" value="strawberry">
  Java plug-in required to view this applet.
</applet>

If the JAR is in the same folder as the JSP, archive="SampleApplet.jar" will work; otherwise adjust the relative path.

Important compatibility note: mainstream browsers and the Java platform have deprecated and removed support for browser applets and NPAPI plug-ins. Chrome and other vendors removed NPAPI support years ago, and Oracle deprecated the Java applet/Web Start deployment stack in JDK 9 and removed it in later releases. That means even a correctly deployed applet may not run in modern browsers; use an older/legacy browser with the Java plug-in or a testing tool (static HTML + appletviewer on legacy JDKs) for validation, or plan to port the functionality away from applets. (blog.chromium.org)

Quick troubleshooting checklist:

  • Confirm the browser actually requested the JAR (Network tab / HTTP 200).
  • If the JAR request fails with 404/403, fix its public location (not under WEB-INF).
  • Check the jar contents (package path).
  • If the browser blocks the plugin, test with legacy environment or a local static HTML + appletviewer for debugging, then consider migrating to a non-applet solution.

Just run in browser.. in eclipse it wont show the applet so u have to run in Browser like IE or Mozilla

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.