I have a problem sending a serialized object (instance of a class that is not part of the Java Core API) from a servlet to an applet. I don't have a problem to send a serialized String object though - everything works fine (even in both directions). But when I replace the String object to be sent by the servlet to the applet with an object of a class defined by me, server showing 500 status code saying internal server error. The servlet itself seems to have finished its work completely. I use Tomcat 4.1.29 and j2sdk1.4.2.
Any idea will be highly appreciated. Thanks in advance.
Have you checked the server logs to find the exception which caused the server error? I would bet that your custom object does not implement Serializable. You must implement Serializable or Externalizable in order to serialize an object. Have a look at the Java Tutorial on Object Serialization.
thank you very much for your sincere response.now that problem is over. Could you please tell me the steps to connect to mysql database from an applet.(I dont want to use the servlet to get access to database). I just want to communicate with database from my applet.
I know JDBC very well,but the problem is my applet is throwing some security exception.Many people told me that applet cant talk to database directly.We need some POLOCY files to communicate with the database.I am asking about that stuff joe.
I approached this situation by using a servelet, but rather than send it a sql query to run, I send it an object that contains a string for constructing a PreparedStatement ("select * from mytable where key = ?") and a vector containing the parameters to complete the statement I realize this isn't absolutely secure but it's much better than passing human readable strings It was suggested to me that using JDBC to talk straight to the DB is a bad idea because you have to leave the DB's communication port open to the public