• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

serializable problem

 
achayya matta
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ranchers,

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.
 
Joe Ess
Bartender
Posts: 9337
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
achayya matta
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello joe,

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.

Please help Joe.Its too urgent man.

thank you in advance
 
Joe Ess
Bartender
Posts: 9337
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ease Up. Every question on JavaRanch is "urgent".
Have you looked at the Java Tutorial on JDBC or our own JDBC FAQ? If so, what specific questions do you have?
 
achayya matta
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello joe,

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.

if you know those things please explain me joe.
 
Dave Robbins
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

Thoughts??

Dave
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are two ways of enabling an applet to talk to a database that's not on the same host as the web server: policy files and digital signing. Both are explained in this wiki page.

And yes, it is problematic to have an applet talk to a database directly. Going through a servlet avoids many potential problems with that approach.
[ July 11, 2006: Message edited by: Ulf Dittmer ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic