Servlet- applet serial'n

Hi and thanks in advance if you can help.
I'm trying to serialize an object in a servlet and send it to an applet. The applet is giving me a ClassCastExecption: Bad magic number error, but I'm pretty sure that's a time-out error--the servlet appears to be hanging at the writeObject(myObj) statement. The code follows the straightforward examples I've found. Before I post the code, note that the following tests have succeeded:
-- using the same methods, sending a serialized String to the applet.
-- serializing my object to disk, then de-serializing it.
Also, please note that myObj can range in size from about half a Mb on up to nearly 3Mb, at least for now.
SERVLET SNIP
//res is the ServletResponse instance
res.setContentType("application/x-java-serialized-object");
oos = new ObjectOutputStream(res.getOutputStream());
oos.writeObject(myObj);
oos.flush();
oos.close();APPLET SNIP
private URL servletURL;
private HttpURLConnection con;
servletURL = new URL( getCodeBase(), "AppletMinder" );
con = (HttpURLConnection)servletURL.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setDefaultUseCaches(false);
con.setUseCaches(false);
//set content type for serialized objects
con.setRequestProperty("Content-Type","application/x-java-serialized-object");
//params sent to servlet, servlet populates a myObj instance -- all working.
//showing that it's threaded just for completeness
Thread t = new Thread(new Runnable() {
     public void run() {
          sendToServlet(params);
          myObj= receiveFromServlet();
t.start();
//from the receiveFromServlet() method...
input =     new ObjectInputStream(con.getInputStream());
myObj = (MyObj)input.readObject();
input.close();Okay, so to repeat, everything worked when I substituted a String for myObj.
Also when I serialized to disk as follows...
File test = new File("C:/test.bin");
ObjectOutputStream oos;
oos = new ObjectOutputStream(
     new BufferedOutputStream(
          new DeflaterOutputStream(
               new FileOutputStream(test, false), new Deflater(Deflater.BEST_COMPRESSION)), 4096));...then de-serialize and read it back in it works, so I know myObj is truly serializable. The problem seems to be with wrapping the ServletOutputStream in the ObjectOutputStream because the servlet appears to hang there.

An update:
MyObj has a number of primitive instance variables, an ImageIcon, and two vectors of other objects (myObjA and myObjB). In a typical populated myObj instance, the ImageIcon is by far the largest variable, so I tried serializing and sending just the ImageIcon instead of the whole myObj, and it worked.
However, when I try to serialize and send either of the vectors it fails (on the applet side) in the same way as when I tried sending the whole myObj (ClassFormatError: Bad magic number--I mistated the error above--it's a ClassFormatError, not a ClassCastException).
So I was wrong, the problem seems to be on the client/applet side. Is this possibly related to the plug-in vs. the VM? At compile time both the applet and servlet use the same environment within my IDE. I'm using 1.4.1_01.

Similar Messages

  • Servlet Applet object communication problem???!!!

    Hy folks,
    I need to validate the ability of complex Servlet Applet communication an run into my first pb right at the beginning of my tests. I need to have around 200 Applet clients connect to my servlet and communicate by ObjectInput and ObjectOutput streams. So I wrote a simple Servlet accepting HTTP POST connections that return a Java object. When the java Applet get instantiated, the Object Stream communication workes fine. But when the Applet tries to communicate with the servlet after that, I can not create another communication session with that Servlet, instead I get a 405 Method not allowed exception.
    Summarized:
    - Applet init() instantiate URLConnection with Servlet and request Java object (opening ObjectInput and Output Stream, after receaving object, cloasing streams).
    - When I press a "get More" button on my Applet, I am not able to instantiate a new URLConnection with my servler because of that 405 exception, WHY???
    Here my Servlet code:
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
             ObjectInputStream inputFromApplet = null;
             ArrayList transmitContent = null;       
             PrintWriter out = null;
             BufferedReader inTest = null;
             try{               
                   inputFromApplet = new ObjectInputStream(request.getInputStream());           
                     transmitContent = (ArrayList) inputFromApplet.readObject();       
                     inputFromApplet.close();
                     ArrayList toReturn = new ArrayList();                 
                     toReturn.add("One");
                     toReturn.add("Two");
                     toReturn.add("Three");
                     sendAnsweredList(response, toReturn);                 
             catch(Exception e){}        
         public void sendAnsweredList(HttpServletResponse response, ArrayList returnObject){
             ObjectOutputStream outputToApplet;    
              try{
                  outputToApplet = new ObjectOutputStream(response.getOutputStream());          
                  outputToApplet.writeObject(returnObject);
                  outputToApplet.flush();           
                  outputToApplet.close();              
              catch (IOException e){
                     e.printStackTrace();
    }Here my Applet code:
    public void init() {         
             moreStuff.addActionListener(new ActionListener(){
                  public void actionPerformed(ActionEvent e){
                       requestMore();
             try{
                  studentDBservlet = new URL("http://localhost/DBHandlerServlet");              
                  servletConnection = studentDBservlet.openConnection();      
                   servletConnection.setUseCaches (false);
                   servletConnection.setDefaultUseCaches(false);
                   servletConnection.setDoOutput(true);
                   servletConnection.setDoInput(true);
                   ObjectOutputStream outputToApplet;
                 outputToApplet = new ObjectOutputStream(servletConnection.getOutputStream());          
                 outputToApplet.writeObject(new ArrayList());
                 outputToApplet.flush();           
                 outputToApplet.close(); 
                   ObjectInputStream inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
                   ArrayList studentVector = (ArrayList) inputFromServlet.readObject();
                   area.setText("Success!\n");
                   for (int i = 0; i<studentVector.size(); i++) {
                        area.append(studentVector.get(i).toString()+"\n");
                  inputFromServlet.close();
                  outputToApplet.close();             
              catch(Exception e){
                   area = new JTextArea();
                   area.setText("An error occured!!!\n");
                   area.append(e.getMessage());
            getContentPane().add(new JScrollPane(area), BorderLayout.CENTER);
            getContentPane().add(moreStuff, BorderLayout.SOUTH);
        private void requestMore(){
             try{              
                  studentDBservlet = new URL("http://localhost/DBHandlerServlet");                             
                  servletConnection = studentDBservlet.openConnection(); 
                   ObjectInputStream inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
                   ArrayList studentVector = (ArrayList) inputFromServlet.readObject();
                   area.setText("Success2!\n");
                   for (int i = 0; i<studentVector.size(); i++) {
                        area.append(studentVector.get(i).toString()+"\n");
              catch(Exception e){               
                   area.setText("An error occured2!!!\n");
                   area.append(e.getMessage());
        }Can someone help me solv this issue please, this is my first Applet Servlet work so far so I have no idea on how to solve this issue.

    Sorry folks, just found my error. Forgot about the ObjectInputStream waiting on the Servlet side, so of course had a dead look...
    Sorry!

  • Servlet/Applet communication, data limit?

    I have an applet that uses a servlet as a proxy to load/retrieve images from an Oracle database. I have a problem when trying to retrieve images larger than 9-10kb from the database. When using JDBC from a Java Application I don't have any probelms but through the Applet-Servlet configuration I do.
    I use the following code in the Applet:
    URL url =new URL("http","myserver",myport,"/servlet/MyServlet");
    HttpURLConnection imageServletConn = (HttpURLConnection)url.openConnection();
    imageServletConn.setDoInput(true);
              imageServletConn.setDoOutput(true);
              imageServletConn.setUseCaches(false);
    imageServletConn.setDefaultUseCaches (false);
    imageServletConn.setRequestMethod("GET");
    byte buf[] = new byte[imageServletConn.getContentLength()];
    BufferedInputStream instr = new BufferedInputStream(imageServletConn.getInputStream());
    instr.read(buf);
    Image image = Toolkit.getDefaultToolkit().createImage(buf);
    // then code to display the image
    And the following for the Servlet:
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("image/gif");
    byte[] buff = loadImage(); // this method returns a byte array representing the image.
    response.setContentLength(contentLength);//contentLength is the size of the image
    OutputStream os = response.getOutputStream();
    os.write(buff);
    os.close();
    thanks in advance!

    thanks for your replay,
    I tried your suggestion but whatever I do it seems that tha applet only brings the first 5-10k of the image from the servlet. This is the value I get from instr.read() or any other type of read method. The value of bytes is not always the same.
    Now I also have something new. For images greater than 100k or so I get this error:
    java.io.IOException: Broken pipe
         at java.net.SocketOutputStream.socketWrite(Native Method)
         at java.net.SocketOutputStream.socketWrite(Compiled Code)
         at java.net.SocketOutputStream.write(Compiled Code)
         at java.io.BufferedOutputStream.write(Compiled Code)
         at org.apache.jserv.JServConnection$JServOutputStream.write(Compiled Code)
         at java.io.BufferedOutputStream.write(Compiled Code)
         at java.io.FilterOutputStream.write(Compiled Code)
         at interorient.DBProxyServlet.doGet(Compiled Code)
         at javax.servlet.http.HttpServlet.service(Compiled Code)
         at javax.servlet.http.HttpServlet.service(Compiled Code)
         at org.apache.jserv.JServConnection.processRequest(Compiled Code)
         at org.apache.jserv.JServConnection.run(Compiled Code)
         at java.lang.Thread.run(Compiled Code)
    I am using the Oracle Internet application server (ias 9i) which actualy uses the apache web listener.
    It seems that this servlet-applet communication is really unstable. If you have anything that may help me it will be greatly appriciated. You can even e-mail me at [email protected]
    thanks!

  • Applet - Servlet - Database - Servlet- Applet

    Hi All,
    I am using Oracle8i and IE 5.0. I am trying to retrieve the data from a db table and display it.
    Sequence is as following:
    1. Query passed to the applet.
    2. Servlet excutes this query using JDBC and returns the resultset to applet.
    3. Applet displaysthe results.
    Is there anybody who has a code sample to do this, my id is [email protected] ? I am totally new to java and servlets. I would really appreciate any help.
    Thanks a lot.
    Manuriti
    [email protected]

    I've never dealt with the code to handle the applet portion of what you're trying to do, but I can help you with the servlet stuff.
    Your servlet should contain code to accomplish the following steps:
    1. Load an Oracle JDBC driver into memory.
    2. Open a JDBC connection to the Oracle database.
    3. Create a JDBC Statement object which contains the appropriate Oracle SQL code.
    4. Execute the Statement object, which will return a ResultSet.
    5. Read the ResultSet data.
    6. Pool or close the Statement and Connection objects.
    All of these steps are simple. Here's what they might look like in practice:
    // load the Oracle driver
    Class.forName("oracle.jdbc.driver.OracleDriver");
    // open the connection
    String cs = "jdbc:oracle:[email protected]:1521:DBNAME"; // connection string
    String userName = "scott";
    String password = "tiger";
    Connection con = DriverManager.getConnection(cs, userName, password);
    // create a Statement object
    Statement stmt = con.createStatement();
    // create a ResultSet object
    ResultSet rs = stmt.executeQuery("select * from DUAL"); // your SQL here
    // INSERT CODE HERE TO READ DATA FROM THE RESULTSET
    // close the Statement object
    stmt.close();
    // close the Connection object
    con.close();
    So that's how you get data from your Oracle database. Now, how do you pass it to your applet? Well, this is hardly trivial. Typically, servlets return an HTML-formatted text stream. It is possible to have an applet communicate with a servlet, but that raises security issues that I don't fully understand. I believe you would have to have your user's browsers set to the lowest possible security settings, otherwise the browser won't let the applet open a socket to a foreign IP, but again, I'm shaky on that one.
    Anywho, let me know if this was of help and if you have more questions on the servlet/applet stuff. I can probably help you with more specific questions,.

  • Servlet applet object io streams

    hi! i have an applet and servlet which communicate through objectoutputstreams.
    here's part of my applet code found in the init method:
    hostServlet = new URL( "http://localhost:8080/scheduler/servlet/EditSchedule" );
    hostConnection = (HttpURLConnection)hostServlet.openConnection();
    hostConnection.setRequestMethod( "POST" );
    System.out.println( "connected" );
    //set headers
    hostConnection.setDoInput( true );
    hostConnection.setDoOutput( true );
    hostConnection.setUseCaches( false );
    hostConnection.setDefaultUseCaches( false );
    hostConnection.setRequestProperty( "Content-Type", "application/x-java-serialized-object" );
    //stream to servlet just to specify that we're using post not get
    oos = new ObjectOutputStream( hostConnection.getOutputStream() );                                      
    oos.writeObject( "inside" );                                                
    oos.flush();
    oos.writeObject( "inside2" );
    oos.flush();
    //get objects being passed by servlet
    ooi = new ObjectInputStream( hostConnection.getInputStream() );
    here's part of my servlet code in the doPost() method:
    ObjectOutputStream oos = new ObjectOutputStream( response.getOutputStream() );
    ObjectInputStream ois = new ObjectInputStream( request.getInputStream() );
    response.setContentType( "application/x-java-serialized-object" );
    oos.writeObject( object );               
    oos.flush(); 
    oos.close();     
    //read objects
    FileOutputStream fw = new FileOutputStream( "c:\\objectsRead.txt" );
    ObjectOutputStream objectFw = new ObjectOutputStream( fw );
    objectFw.writeObject( "from servlet" );
    objectFw.flush();                                 
    String inside = (String)ois.readObject();
    objectFw.writeObject( inside );
    objectFw.flush();
    String outside = (String) ois.readObject();
    objectFw.writeObject( outside );
    objectFw.flush();
    objectFw.close();both the inside and inside2 objects get written to my textfile. Although, in my applet, if i outputted inside2 after creating the objectinputstream, only inside1 gets written. This is my problem. I have to write back to the servlet way passed the ooi instantiation of the applet. Specifically, in an event handler outside the init method.
    any help would be greatly appreciated! =)

    another weird thing that i found out.
    when i use the syntax:
    oos.writeObject( "something" );
    -->it gets passed to the servlet while
    String str = "something";
    oos.writeObject( str );
    -->doesn't get passed.
    hmm....
    i tried setting the content type to application/octet-stream but still nothing.

  • Inconsistent Stream responses b/w servlet & applet

    Hi all,
    I am facing problem with my servle/applet communication .I am using serialized object transport b/w the two. I am able to send my object using a URL connection class successfully to the server .
    However having problems while reading the response on the applet .
    It's been so incosistent that I sometimes think of switching over to some activex control instead of an applet .
    I have been struggling with this one for quite sometime . Somebody help to fix this out!
    First to the problem faced by me
    Some times I get StreamCorruptedException saying Input stream does not contain serialized object .
    Some times I get EOFException saying Invalid Header-1.
    Why so much inconsistency when I am passing the same serialzed object CStreamData? Anyone's valueable input is highly appreciated.
    My part of code that reads the object sent from the servlet.
    public CStreamData ReadResObj(CServerRequest oRequest)
    CStreamData objResponse = null;
    isServerRunning = true;
    try {
    URL url = new URL( "http://localhost:8080"+
    "/apps/servlet/MWServer");
    URLConnection con = url.openConnection();
    con.setUseCaches(false);
    con.setRequestProperty("CONTENT_TYPE","application/octet-stream");
    con.setDoInput(true);
    con.setDoOutput(true);
    ObjectOutputStream out = new ObjectOutputStream(con.getOutputStream());
    out.writeObject(oRequest);
    out.flush();
    out.close();
    ObjectInputStream ois = new ObjectInputStream(con.getInputStream());
    //The exception is thrown here while reading...
    objResponse = (CStreamData)ois.readObject();
    ois.close();
    }catch (Exception e)
    isServerRunning = false;
    return (CStreamData)objResponse;
    return (CStreamData)objResponse;
    }//End of readResObj
    Best rgds,
    prithvi

    It would be interesting to see what's the response of your servlet.
    Mybe the response of your servlet is an error html page
    which of course can't be converted into Object of Type CStreamData.
    You should think about doing some error handling before you try read from the ObjectInputStream an before you think about using ActiveX components.
    for example
    URLConnection con = url.openConnection();
    HttpURLConnection httpConnection;
    try
      URL url = new URL( "http://localhost:8080"+"/apps/servlet/MWServer");
      URLConnection con = url.openConnection();
      httpConnection = (HttpURLConnection)con;
      out.close();
      if(  httpConnection.getResposeCode() == HttpURLConnection.HTTP_OK )
         ObjectInputStream ois = new ObjectInputStream(con.getInputStream());
         objResponse = (CStreamData)ois.readObject();
         ois.close();
    }If you still have problems dump the content of your servlet response
    to the console and tell what you see or post parts of the response.

  • Applet  + Serialized Object + PDF == ??

    I have an applet that serializes a transport bean to a servlet on tomcat, based on the contents of the bean, the servlet makes a PDF that I want to display on the browser.
    I had thought that if I simply set the response MIME type and return the binary data, the browser would know what to do. Silly me, but I forgot that in this case the applet is the one in control, not the browser. The browser screen just sits there. At least this is what I am guessing...
    Here is the code that I use to send the serialized object :
        public InputStream sendPostMessage (Properties args) throws IOException
            String argString = "";  // default
            if (args != null)
                argString = toEncodedString (args);  // notice no "?"
            URLConnection con = servlet.openConnection ();
            // Prepare for both input and output
            con.setDoInput (true);
            con.setDoOutput (true);
            // Turn off caching
            con.setUseCaches (false);
            // Work around a Netscape bug
            con.setRequestProperty ("Content-Type", "application/x-www-form-urlencoded");
            // Send headers
            sendHeaders (con);
            // Write the arguments as post data
            DataOutputStream out = new DataOutputStream (con.getOutputStream ());
            out.writeBytes (argString);
            out.flush ();
            out.close ();
            return con.getInputStream ();
        }Here is the question...
    Given the fact that I am serializing an object to the servlet, and that the applet is sitting there.. Is there a way to make the Browser display the PDF?
    I have my doubts about ShowDocument(URL) as I am generating the PDF on the fly without using a temporary file. (Jasper reports) In addition, aren't there sandbox issues on the server side for creating a file?
    Any other ideas?

    I think that IS what I will have to do but, I was hoping to use the PDF binary stream coming directly from the servlet.
    I guess this isn't possible?

  • Servlet/applet problem

    hi guys
    my problem is that, i started my tomcat server, also my servlet. this servlet should call an applet. so here are my questions:
    where must be the applet class file?
    how looks like my codebase?
    what code must i type into the servlet? something special?
    do i need an apache server additional?
    yes? where must be my files? :)
    hope anyone can help me...
    bye

    keep the applet class file in the home directory, the directory in which your index.html lies, index.html -- the html which shows up when you say http://localhost:8080
    and then give the applet description like this in the servlet
    out.println("<applet code=\"myApplet.class\" codebase=\"http://localhost:8080\" width=\"400\" height=\"400\"> ");
    out.println("</applet>");
    and that should work and you will be good to go

  • Servlet-applet

    hello
    I have an html file, on which an applet is displayed. This applet is actually a frame on which there is a FileDialog. I select a file, and I want to send this String corresponding to the path of the file, to a servlet. But then, I want to stay on the servlet, and not send a response from the servlet to the applet.
    here is my code:
    html:
    <p><form action="servlet/SetOfServicesRegistrationServlet">
    <P>
    <applet code="mobi/das/aca/managementServlets/Openfile.class" width=400 height=100>
    </applet>
    <br /><br />
    Add this list of services
    <input type="submit" value="Add">
    </form>applet:
    public void actionPerformed(ActionEvent evt){
              String composant = evt.getActionCommand();
              if( composant.equals("Open") ){
                             fileToLoad = fd.getDirectory().concat(fd.getFile());
                             try{
                                  String codedValue = URLEncoder.encode(fileToLoad,"ISO-8859-1");
                                  URL url = new URL(getDocumentBase(),"http://asterix:8080/acamanager_2/servlet/SetOfServicesRegistrationServlet?message="+codedValue);
                                  URLConnection connexion = url.openConnection();
                                  BufferedReader reponse = new BufferedReader(new InputStreamReader(url.openStream()));
                             catch(IOException error){}
                        and the servlet:
    public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException, ServletException{
               response.setContentType("text/html");
               response.setBufferSize(1000);           
               PrintWriter out = response.getWriter();
               //we get the parameters sent by the html form
               String fileLocation = request.getParameter("message");
               System.out.println(fileLocation);What I'd like to see, is just a servlet, on which the path of the file is displayed.
    Any ideas?
    Help me please. I've been looking for it for too long now
    Thanks in advance
    Philippe

    Hi, thanks for the reply, let me clarify, the main
    thread is initiated by the servlet. In other words,
    the servlet is called and simply starts my Thread
    class which takes over.A thread started by a servlet, that is really a bad design and bound to cause memory leaks plus deadlocking isssue.
    So, I want my Thread Class to communicate with the
    applet during runtime. The Thread Class is simply an
    object extending the Thread java class.
    The servlet itself does not do anything - it starts
    the process and then it simply receives the results
    and outputs them to the client.just use the javax.servlet.ServletOutputStream class as one of the parameters to ur thread class. that way the thread can communicate with the applet. but i have to warn you again.
    good luck

  • Communication between servlet & applet

    Hello everybody,
    Well, I have a problem with my applet/servlet system.
    I Would like my applet to send some queries to the servlet.
    However, I don't know how to link the applet with the servlet (the only way I know is to use "openConnection()", but I don't see how to incorporate my query in the URLConnection (in order to have one, I need openCOnnection, and once it's done, well, the doGet method has already be laucnh, without any parameter to read). In my case, the DoGet methods of the servlet is launched, and of course, the HTTPRequest is almost empty, seeing thath I don't see how to specify the differnets parameters.
    Is thereany simple meaning to make the applet communicate this the servlet, sending strings, and receiving objects (I have already solve the problem of the sending of an object from the servlet to the applet, in the doGet method).
    Thank you very much
    C U

    In the applet html include a servlet parameter.
    <param
    name="servlet"
    value="/SqlServlet" />
    In your applet open a connection to servlet.
    InputStream in = null;
    URLConnection conn = null;
    URL url = null;
    String servlet = getParameter("servlet");
    url = new URL(servlet + "?sql=" + URLEncoder.encode(sql));
    conn = url.openConnection();
    in = conn.getInputStream();

  • Servlet applet communication

    I'm having a problem getting a servlet to answer a call from an applet...in the applet I do something like:
    String servlet = "http://192.168.123.148/root/MyServlet.class";
    url= new URL(servlet);
    conn = url.openConnection();
    conn.setUseCaches(false);
    in = conn.getContentLength();
    String contype = conn.getContentType();
    And in the servlet:
    java.io.PrintWriter out = response.getWriter();
    response.setContentType("text/html");
    response.setHeader("segment",Integer.toString(99));
    out.flush();
    The problem is I don't get my header back in the applet...and when I look at the content type, its "application/java-vm"...not " text/html"...as I set in the servlet...???

         InputStream urlInput = null;
         HttpURLConnection urlConn =  null;
         URL url = new URL(urlStr);
         urlConn = (HttpURLConnection)url.openConnection();
         urlConn.setDoInput(true);
         urlConn.setDoOutput(true);
         urlConn.setUseCaches(false);
         urlConn.setRequestMethod("POST");
         urlConn.setRequestProperty("Accept-Language", "en");
         urlConn.setRequestProperty("content-type", "text/xml");
         urlInput = urlConn.getInputStream();

  • How can I generate a html page in a servlet-applet connection?

    Hello, I have an applet which contains an ok button, when I click this button, I need that servlet generate an html page and view it in browser. How can I do this?
    Thanks

    But with this method only is possible I think open a page web, and if it is possible call url of the servlet, you generate other request and response object (other call to method doGet or doPost because ShowDocument needs parameter url), so the previously request when I click button ok it's no the same and how I obtain the prinwriter from first request, showDocument don't obtain html page from printwriter.

  • Servlet-Applet project. Architectural problem.

    Hello, everybody!
    I'm to make client-server web project, client works with different databases via server (using servlet). The protocol of the project is as follows:
    - Client requests to �erver and gets applet.
    - All communications between client and server are to be made via applet-servlet. So, client makes some operations using applet, then sends data to server. After the data being processed on the server side, client gets the possibilities to make further operations.
    The problem is choosing the proper architecture. Having sigle applet and processing communications with single applet-servlet is not good, because I need to get client the possibility to choose database, then choose table, edit records and so on. I want to have applets for every type of operations. I mean, after client gets start applet, he sends the request to server, which processes it and gets another applet for database choosing and so on.
    The question is: is it possible to build such architecture with many applets and data transfers between them?

    Why does it need to be through applet?
    Why can't the same applet take care of most (all?) your database chores?

  • Servlet/applet/socket problem

    Hi there,
    my problem is this...
    i create a page with an servlet whicht shows an applet. this applet connects to a server through an socket. it works fine, but, when i change the page and the applet is not longer on the screen, the socket connection will be not killed! i dont know why. but i must kill it when the applet is not longer on the screen...whats wrong? can you help me?
    matthias

    Are you overriding the destroy() method in your Applet? This will be called when the applet is about to be unloaded from the browser. Or, as a slightly different alternative, you can override the stop() method, which is called when the applet is scrolled off the screen. Usually when stop() is used, start() is overriden as well to allow the applet to resume when it is scrolled back into view. For more info, read up on the applet lifecycle.

  • Servlet applet  : ClassNotFoundException

    i m using jrun for testing servlet
    i have created a servlet and it prints the following
    out.println("<html>");
    out.println("<body>");
    out.println("<applet code=\"MyApplet\" width=\"200\" height=\"200\"></applet>");
    out.println("</body>");
    out.println("</html>");
    but when this page load in browser it shows an error
    ClassNotFoundException is throwns
    i have place MyApplet.class in root directory of jrun as well as root\web-inf\classes
    but it didn't work

    Specify the codebase in the applet tag.

Maybe you are looking for