Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Servlets and the fly likes applet to servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "applet to servlet" Watch "applet to servlet" New topic

applet to servlet

Eva Adams

Joined: Jan 12, 2004
Posts: 5
I'm working in an web speech recognizer.
I need to record/play audio, but applet policy doesn't allow it without signing the applet o making each user modify his java.policy. I don't want to sign the applet (no money ) and the second option is tedious for the user.
I've programmed the applet and i don't want to rewrite it as servlet
There's an easy way to convert an applet to a servlet?
If not, there's an easy way to make applet communicate with servlet? i mean, create a servlet that records/play audio and pass the information of the audio recorded to the applet.
Thanks in advance,
Dave Robbins
Ranch Hand

Joined: Sep 16, 2003
Posts: 131
Hi Eva,
I've recently been playing with something that might help you.
I have an applet that needs to communicate with a database.
It has same problem you described, it needs to be signed or security policy needs to be changed. So I made a servlet that acts like a database proxy. The applet passed the query it wants to run to the servlet as a string. The servlet runs the query against the database, packs the data up in a custom class I created and returns the object to the applet. The trick is that where the servlet ordinarily returns a string of html to the browser, it can also pass an object to a servlet. The code looks like this
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//PrintWriter fail = response.getWriter();
{ out = new;

String str = request.getParameter("sql");
if(str == null)
// fail.println("<html><body> No Sql! </body></html>");
out.writeObject(doSelect(str ));
}catch(java.lang.Exception e)
//fail.println("<html><body> Exception Occured! </body></html>");
the trick is you don't create a regular output stream but a ObjectOutputStream
Maybe you can return your data this way
Good Luck
I agree. Here's the link:
subject: applet to servlet
It's not a secret anymore!