Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

serializable problem

 
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.
 
Bartender
Posts: 9615
16
Mac OS X Linux 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: 9615
16
Mac OS X Linux 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.
 
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
 
Rancher
Posts: 43016
76
  • 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 ]
 
You know it is dark times when the trees riot. I think this tiny ad is their leader:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic