• 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

where to store the applet file using JWS in servlet technology?

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to call applet from servlet using Java Web Server....so please tell me where can I store the applet class file and how to call the applet from servlet...
Thanking You in advance!
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't call an applet from a servlet, applets run on the browser, not the server. Assuming you mean that you want to have a servlet generate a page that has an applet in it, the thing to remember is that the browser has to request the applet code from the server, just like it has to request images, etc. Image and applet class files have to be put where the server can find them, just like when a normal html page with an image or applet is served.
The problem is that a page coming from a servlet looks to the browser like it is coming from an address that can't serve images and applet class files. The solution is to either:
1. give an absolute URL in the applet tag or
2. put a <base href="url_where_the_applet.class_files_are"> tag in the <head> area of the html page you build.
Bill
 
honey singh
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi William,
Thank You very much for the reply..but still the problem is persisting... actually the servlet is returning a page that has applet in it, now I had tried both of the options,like specifying the whole URL
<applet code="userinter.class" codebase="http://localhost:8080/public_html/student">
and same with the
<head>
<base href="same url as above">
</head>
but its giving the following error "java.lang.ClassNotFoundException:userinter.class"
any type of help will be appreciated.
Thank You!
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That looks like it should work. Is the userinter class in a package? If so you need to include the package name, and the codebase should point to the directory where the package starts.
code="mypkg.userinter.class" codebase="http://localhost:8080/public_html/student/">
where the class lives in:
server root/public_html/student/mypkg/userinter.class
Bill
 
honey singh
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bill,
Again thanx a lot for the reply, but the problem is still there...I'll now tell u the whole thing..I'm using JWS 1.1.3 now when I compile it using this, it says that it can't import javax package...so I'm compiling the servlet file and other files using Oracle JDeveloper and then copying the files from its directory to the directory of JWS...now I'm not using any packages, so then again the problem persists..and the whole code for the servlet is
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import oracle.sql.*;
import java.util.*;
public class input extends HttpServlet{

public void init(ServletConfig config) throws ServletException {
super.init(config);
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

String registrationID = "";
HttpSession session = request.getSession(true);
registrationID=(String)session.getValue("registration");
response.setContentType("text/html");
PrintWriter out = new PrintWriter (response.getOutputStream());
out.println("<html>");
out.println("<body>");
out.println("<applet code=\"userinter.class\" codebase=\"http://its_78:8080/public_html/student/\" height=400 width=400>");
out.println("<param name=\"r1\" value=registrationID>");
out.println("</applet>");
out.println("</body>");
out.println("</html>");
out.close();
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
}
}
now the applet's class files are in
serverroot/pubic_html/student/userinter.class and also other files userinter$A,$B,$C,$D,$E which I had defined in the userinter.java file which contains these Classes A,B,C,D,E...and the userinter.java file is in the JDeveloper's directory...
so this is all .....
so again please help me..
Thank You!
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would try to get the applet running from a static HTML page first. Once you have that, I would compare the source of the HTML page your servlet is writing versus the static page to see what is different.
For example, is your entire server running through port 8080? Your servlet code:
out.println("<applet code=\"userinter.class\" codebase=\"http://its_78:8080/public_html/student/\" height=400 width=400>");
indicates you expect it to be.
Bill
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at JavaRanch's naming policy. . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
 
honey singh
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank You very much for the reply again, now this time it worked..I just put the applet's class files in the public_html directory and wrote the tag as
<applet code="userinter.class" codebase="http://its_78:8080">
and vow it worked..
Thanx once again William for the favourable reply.
bye.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic