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
posted
0
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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.