Solved

Include Applet tag in Java Servlet

Posted on 2002-07-14
3
312 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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 basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

746 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now