File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "applet to servlet" Watch "applet to servlet" New topic
Author

applet to servlet

Eva Adams
Greenhorn

Joined: Jan 12, 2004
Posts: 5
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
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();
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: applet to servlet
 
Similar Threads
how play movie in applet
Playing multiple audios
Cached audioclip
How to play audio stream in browser which is stored in database?
Playing Audio on Web Server via Applet using JMF