• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

"Sending Applet through Servlet"

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,
I have written servlet that on request returns Applet.I have stored applet's ".java", ".class" &".jar" files in
c:\jsdk2.1\examples\WEB-INF\servlets & I have stored my servlet which handles the request in the same directory .
I write ".html" file of applet in my servlet & send it as response.
I have written codebase value="." i.e. current directory ,but when I request that servlet from browser, it shows the message like "Applet is Loading", & in status bar it shows the message like "class file" not found .
So where the class file of applet should be stored?
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take the applet's .class file out off the WEB-INF directory. And place it in the same directory as your WEB-INF directory. And use this codebase ".." instead of "." and your code attribute should be the be the applet's name .class file.
Hope that helps
 
snehal holgundikar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,
I have taken ".class" file outside of the WEB-INF & put it in current directory. But still it is not working,is this due to JSDK2.1 or any other problem? Is it get solved by using APACHE server?
 
Tod Checker
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is your codebase? Can you cut and paste your code?
 
snehal holgundikar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
now i am using apache server.
i have put class file in root directory of server which is accessible to browser. i hava also stored images in that directory . the images are accessed but class file is not found by browser.
my code for servlet is
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class hmpageserv extends HttpServlet
{

public void doGet (HttpServletRequest req,HttpServletResponse resp)
{
System.out.println("Servlet Started");
String s1="\"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93\"";

try
{
resp.setContentType("text/html");
PrintWriter pw=resp.getWriter();


String str="<html><body><OBJECT classid="+s1+" HEIGHT = 480 WIDTH = 760 >"
+"<PARAM NAME = CODE VALUE = http://127.0.0.1\\hmpage ></OBJECT>"
+"<APPLET CODE =http://127.0.0.1\\hmpage CODEBASE =\"http://127.0.0.1\\""
+ "ARCHIVE =\"http://127.0.0.1\\hmpage.jar\" HEIGHT = 480 WIDTH = 760 >"
+"</APPLET>"
+" </body>"
+"</html>";
System.out.println(str);
pw.println(str);

pw.close();

}catch(Exception e){System.out.println("error"+e);}
}
}
 
Tod Checker
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try changing your code attribute to CODE=hmpage.class(if hmpage.class is your class file).
Your CODEBASE points to the location of CODE, so you don't have to repeat http://127.0.0.1/
 
Tod Checker
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should also put in the port number of your web server next to the local address.
http://127.0.0.1 ortnumber/
 
snehal holgundikar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for ur urjent reply,
i have removed code base & put whole path with file name in code, also specified port no. still it is not working
reply
    Bookmark Topic Watch Topic
  • New Topic