File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes ServletRunner Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "ServletRunner" Watch "ServletRunner" New topic
Author

ServletRunner

Savio Mascarenhas
Ranch Hand

Joined: Nov 29, 2000
Posts: 108
If an applet is invoked from within a servlet ,what should the code attribute of the applet tag specify cause ... i get an error "<appletname> APPLET NOT FOUND" .How should i specify the syntax if the applet is placed in the servers root directory ie.JSDK2.0.
Thanx.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12675
    
    5
Because as far as a browser is concerned, a page created by a servlet comes from some weird URL, you have to make special provision for things like images, sound files and applet class files. You can:
1. provide an absolute URL for every resource
2. use the <base> tag in the <head> area of the page to define a base url where the browser can look for images, etc. that have relative addresses.
<base href="http://myserver/myapplication" />
Bill
------------------
author of:


Java Resources at www.wbrogden.com
Harish Ramamurthy
Greenhorn

Joined: Jul 02, 2001
Posts: 5
Hi William,
I am facing the same path problems. I want to pop out an applet from a servlet.Presently I am using JSDK2.1. I have put the jsdk directory in d:\ i.e. d:\jsdk2.1. Now I have placed my applet class in the directory d:\jsdk2.1\examples\web-inf\servlets. I have also placed a simple servlet in the same location. In the servlet's doGet() method I just return the following HTML code in response.
<html>
<head>
<base href="http://localhost/examples/servlet/">
</head>
<applet code="busGUI" width=200 height=200>
</applet>
</html>
I access my servlet using the URL http://localhost/examples/servlet/MyServer
It gives out an error class busGUI not found. Now When I type the URL http://localhost/examples/servlet/busGUI, It gives an error class cast exception ( which should be there as busGUI is an applet and not a servlet).
I don't understand at all now. Please help me.
Thanks
Harish
Savio Mascarenhas
Ranch Hand

Joined: Nov 29, 2000
Posts: 108
Thanks William ... the <base> tag did the trick.
Subbu Aswathanarayan
Ranch Hand

Joined: Jun 22, 2001
Posts: 73
Hi Harish,
i think there is a small error in ur HTML code.
instead of :
<base href="http://localhost/examples/servlet/">
try this
<base href="http://localhost/examples/servlet" />
do let us know if that works.

Subbu
Originally posted by Harish Ramamurthy:
Hi William,
I am facing the same path problems. I want to pop out an applet from a servlet.Presently I am using JSDK2.1. I have put the jsdk directory in d:\ i.e. d:\jsdk2.1. Now I have placed my applet class in the directory d:\jsdk2.1\examples\web-inf\servlets. I have also placed a simple servlet in the same location. In the servlet's doGet() method I just return the following HTML code in response.
<html>
<head>
<base href="http://localhost/examples/servlet/">
</head>
<applet code="busGUI" width=200 height=200>
</applet>
</html>
I access my servlet using the URL http://localhost/examples/servlet/MyServer
It gives out an error class busGUI not found. Now When I type the URL http://localhost/examples/servlet/busGUI, It gives an error class cast exception ( which should be there as busGUI is an applet and not a servlet).
I don't understand at all now. Please help me.
Thanks
Harish


Subbu
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ServletRunner
 
Similar Threads
Applet
question relating applet
To generate An applet from a servlet
setBounds & setSize bug?
Applet is not sowing the correct size