• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

applet to servlet

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
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,
Eva
 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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();
try
{
java.io.ObjectOutputStream out = new java.io.ObjectOutputStream(response.getOutputStream());

String str = request.getParameter("sql");
if(str == null)
{
// fail.println("<html><body> No Sql! </body></html>");
return;
}
out.writeObject(doSelect(str ));
}catch(java.lang.Exception e)
{
//fail.println("<html><body> Exception Occured! </body></html>");
e.printStackTrace();
}
}
the trick is you don't create a regular output stream but a ObjectOutputStream
Maybe you can return your data this way
Good Luck
Dave
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic