Hi Friends,

I have this issue. I have written an Ajax code(googiespell API-->*
orangoo.com/labs/GoogieSpell/ *) to get the Spell check functionality.

All works fine in IE but it gives me a Security Exception in Mozilla (the
security model is different.)



The gmail server is an outside domain so it throws an exception.

Can you tell me how I can get rid of this error using URL Connection class.

Error:-
---------------
Error: uncaught exception: [Exception... "Access to restricted URI denied"
code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)"  location: "
http://localhost:8080/newproject/ajaxspellchecker.jsp# Line: 247"]
--------------


Client-Side Code
--------------------------------
<script type="text/javascript">
 function spell_check()
 {
  alert("spell check function");
  var val = document.getElementById("txtspellcheckid").value ;
  var googie1 = new GoogieSpell("googiespell/",
"/newproject/spellchecking.jsp?lang=");
  googie1.decorateTextarea("txtspellcheckid");
  alert("done");
 }
  </script>



where txtspellcheckid is the textarea on which spellcheck will work
---------------------------------

Server-Side Script Code
------------------

<%@ page language = "java" %>
<%@ page import = "java.sql.*" %>
<%@ page import = "java.util.*" %>
<%@ page import = "java.io.*" %>
<%@ page import="java.lang.*" %>
<%@ page import="java.net.*" %>
<%


    URL url;
    HttpURLConnection connection = null;
    String lang = (request.getParameter("lang")).trim();
    String urlParameters = "";//"lang=" + URLEncoder.encode(lang, "UTF-8");

    targetURL = https://www.google.com/tbproxy/spell?lang="+lang ;

    try
    {
      //Create connection
      url = new URL(targetURL);
      connection = (HttpURLConnection)url.openConnection();
      connection.setRequestMethod("POST");
      connection.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");

   BASE64Encoder enc = new sun.misc.BASE64Encoder();
      String userpassword = "P09132" + ":" + "jitesh*";
      String encodedAuthorization = enc.encode( userpassword.getBytes() );
      connection.setRequestProperty("Authorization", "Basic " +
encodedAuthorization);

      connection.setRequestProperty("Content-Length", "" +
Integer.toString(urlParameters.getBytes().length));
      connection.setRequestProperty("Content-Language", "en-US");

      connection.setUseCaches (false);
      connection.setDoInput(true);
      connection.setDoOutput(true);

      //Send request
      DataOutputStream wr = new DataOutputStream (
                  connection.getOutputStream ());
      wr.writeBytes (urlParameters);
      wr.flush ();
      wr.close ();

      //Get Response
      InputStream is = connection.getInputStream();
      BufferedReader rd = new BufferedReader(new InputStreamReader(is));
      String line;
      StringBuffer response = new StringBuffer();
      while((line = rd.readLine()) != null) {
        response.append(line);
        response.append('\r');
      }
      rd.close();
      return response.toString();

    } catch (Exception e) {

      e.printStackTrace();
      return null;

    } finally {

      if(connection != null) {
        connection.disconnect();
      }
    }
 ------------------
Client-Side Script (This is all fine. This script calls the JSP page which
in turn calls the Google Spell Check page). This way the above error should
not come. Yet it gives, --->An error was encountered on the server. Please
try again later." prompt

---------------------------\

Please help...I am really thankful for your help in my javamail issue. :).



I request your reply.


Thanks & Regards,
Jitesh Dundas

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Java EE (J2EE) Programming with Passion!" group.
To post to this group, send email to
java-ee-j2ee-programming-with-passion@googlegroups.com
To unsubscribe from this group, send email to
java-ee-j2ee-programming-with-passion-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to