0

I have create a simple Hello World Applet and I have save the .class file to the server where the JSP site is.

I want help so what I have to write in the JSP Site so whenever through the Browser I open this specific JSP Site this applet also run and show the message Hello world.

The JSP site and the .class file from the applet are at the same root, for example *D:\server\tomcat\test*

and also if someone can explain me what is the appletviewer and if I need something like this in my case?

JavaMunich
  • 85
  • 10
  • I suggest you go through some of the 'See also' links from the [Applet tag info. page](http://stackoverflow.com/tags/applet/info) here at SO, remembering that JSP is HTML once it reaches the client. Voting to close this as 'too broad'. – Andrew Thompson Jan 09 '14 at 11:08

1 Answers1

0

You add an applet to an html page. The jsp page gets compiled and when it runs its spits out html. So in your browser all you will have is html.

So you basically need to embedd you applet to the html that is generated by your jsp page.

I would suggest you to do some research on adding your applet to html. Once you have that, simply append the resulting html code (which has the applet) to your jsp page.

Embed the applet in the file by adding the following applet tag anywhere between the file's tags: In an HTML file: <applet code="org.me.hello.MyApplet" archive="HelloApplet.jar"></applet>

In a JSP file: <applet code="org.me.hello.MyApplet" archive="HelloApplet.jar" width="600" height="480"/>

The jsp will ultimately spit out the html code.

sanket
  • 789
  • 4
  • 16
  • Can you please write an example how I embed the applet to the html. – JavaMunich Jan 09 '14 at 10:36
  • You could google it. There are plenty of examples. You could also follow this article https://netbeans.org/kb/docs/web/applets.html – sanket Jan 09 '14 at 11:01
  • Edited the answer. Code included ! – sanket Jan 09 '14 at 11:04
  • where I will fing the .jar file (sorry I am new if I am asking simply things) – JavaMunich Jan 09 '14 at 11:08
  • That first `applet` element is not valid HTML. For a long time now, we have not *needed* to write HTML to launch an applet, instead it can be better handled by the Deployment Toolkit Script (linked from the page mentioned in my comment above). – Andrew Thompson Jan 09 '14 at 11:11
  • WOW...Ok now I see ...great both links from Netbeans and here the Applet tag havent seen it before...Thank you very much – JavaMunich Jan 09 '14 at 11:18
  • but the file of the applet must be a .jar file....? how I make from a .class file to the .jar file...or have to export it like this from NetBeans? – JavaMunich Jan 09 '14 at 13:55