aspose file tools*
The moose likes Servlets and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark ""Sending Applet through Servlet"" Watch ""Sending Applet through Servlet"" New topic
Author

"Sending Applet through Servlet"

snehal holgundikar
Greenhorn

Joined: Mar 11, 2004
Posts: 4
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?
Tod Checker
Greenhorn

Joined: Feb 19, 2004
Posts: 27
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

Joined: Mar 11, 2004
Posts: 4
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

Joined: Feb 19, 2004
Posts: 27
What is your codebase? Can you cut and paste your code?
snehal holgundikar
Greenhorn

Joined: Mar 11, 2004
Posts: 4
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

Joined: Feb 19, 2004
Posts: 27
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

Joined: Feb 19, 2004
Posts: 27
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

Joined: Mar 11, 2004
Posts: 4
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: "Sending Applet through Servlet"