Solved

Include Applet tag in Java Servlet

Posted on 2002-07-14
3
323 Views
Last Modified: 2013-11-24
Hi,

I am writing a programme using Servlet and I have to send a applet to client. So I place the applet tag in the html code in Servlet. However, when I viewed it in browser, it said ClassNotFound Exceptionand in a grey area where I suppose my applet should appear.

My servlet code fragment is as follow:

  response.setContentType("text/html");
  PrintWriter out = response.getWriter();

  out.print("<HTML>"+
         "<HEAD>"+                   "<TITLE>Auction</TITLE>"+
         "</HEAD>"+
         "<BODY>"+
            "<APPLET CODE=\"TemplateVarApplet.class\"  WIDTH=\"300\" HEIGHT=\"300\">"+
         "</APPLET>"+
         "</BODY>"+
         "</HTML>");
out.close();

I place my TemplateVarApplet.class in the same directory as this servlet code.
(both are in C:\Program Files\Apache Tomcat 4.0\webapps\fyp\WEB-INF\classes)

I have try adding codebase to the applet tag but it still can't work.

How to solve this ClassNotFoundException problem in Applet?

Any ideas?
         
Thanks a lot...^^

Sherina
0
Comment
Question by:sherina
  • 2
3 Comments
 
LVL 5

Expert Comment

by:fontaine
ID: 7152191
This is the wrong place. Your TemplateVarApplet.class should be located in the directory containing the WEB-INF subdirectory, i.e. where you place your regular files (HTML, etc.). Don't forget that the .class files that compose your applet are indeed loaded by the browser.
0
 
LVL 5

Accepted Solution

by:
fontaine earned 100 total points
ID: 7152198
You will also have to add the following codebase in your applet tag (I guess that you refer to the servlet with an URL in the style http://www.myserver.com/servlet/MyServlet):

codebase=".."
0
 

Author Comment

by:sherina
ID: 7152529
it work for a while...
but doesn't work now.
dun know what happens...
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
servlet example 11 49
How to write an English digest paper 6 74
going to wrong jsp page 2 33
Java syntax, or is it Selenium 6 30
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question