Loading ...
Sorry, an error occurred while loading the content.

Re: Security Exception - Please help

Expand Messages
  • Caridy Patino
    Hello, Change this line: var oDS = new YAHOO.util.XHRDataSource( http://10.129.203.40:8080/newproject/getautocompleteData.jsp ); for this one: var oDS = new
    Message 1 of 3 , Jul 24, 2009
    • 0 Attachment
      Hello,

      Change this line:
      var oDS = new YAHOO.util.XHRDataSource("http://10.129.203.40:8080/newproject/getautocompleteData.jsp");

      for this one:
      var oDS = new YAHOO.util.XHRDataSource("/newproject/getautocompleteData.jsp");

      It should solve the problem.

      Best Regards,
      Caridy

      --- In ydn-javascript@yahoogroups.com, jitesh dundas <z_jitesh@...> wrote:
      >
      > Hi Friends,
      >
      > I am getting this security exception on Mozilla:-
      >
      >
      > *Error: uncaught exception: [Exception... "Access to restricted URI denied"
      > code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)" location: "
      > http://10.129.203.40:8080/newproject/js/yui/build/connection/connection-min.jsLine:
      > 7"]
      > *
      > *Code:*
      > ----------
      >
      > <html>
      > <head>
      >
      > <link rel="stylesheet" type="text/css"
      > href="http://10.129.203.40:8080/newproject/js/yui/build/fonts/fonts-min.css"
      > />
      > <link rel="stylesheet" type="text/css"
      > href="http://10.129.203.40:8080/newproject/js/yui/build/autocomplete/assets/skins/sam/autocomplete.css"
      > />
      >
      > <script type="text/javascript"
      > src="http://10.129.203.40:8080/newproject/js/yui/build/yahoo-dom-event/yahoo-dom-event.js"></script>
      > <script type="text/javascript"
      > src="http://10.129.203.40:8080/newproject/js/yui/build/connection/connection-min.js"></script>
      > <script type="text/javascript"
      > src="http://10.129.203.40:8080/newproject/js/yui/build/animation/animation-min.js"></script>
      > <script type="text/javascript"
      > src="http://10.129.203.40:8080/newproject/js/yui/build/datasource/datasource-min.js"></script>
      > <script type="text/javascript"
      > src="http://10.129.203.40:8080/newproject/js/yui/build/autocomplete/autocomplete-min.js"></script>
      >
      > <title>Basic Remote Data</title>
      >
      > <style type="text/css">
      > /*margin and padding on body element
      > can introduce errors in determining
      > element position and are not recommended;
      > we turn them off as a foundation for YUI
      > CSS treatments. */
      > body {
      > margin:0;
      > padding:0;
      > }
      > </style>
      >
      > <!--begin custom header content for this example-->
      > <style type="text/css">
      > #myAutoComplete {
      > width:25em; /* set width here or else widget will expand to fit
      > its container */
      > padding-bottom:2em;
      > }
      > </style>
      >
      >
      > <!--end custom header content for this example-->
      >
      > </head>
      >
      > <body class=" yui-skin-sam">
      >
      > <h1>Basic Remote Data</h1>
      >
      > <div class="exampleIntro">
      > <p>This AutoComplete implementation points to an online script that
      > serves a data as delimited plain text. Enabling caching on the
      > DataSource can reduce trips to the server and speed performance for
      > repeated queries.</p>
      >
      > </div>
      >
      >
      >
      > <!--BEGIN SOURCE CODE FOR EXAMPLE =============================== -->
      >
      > <h3>Search our database:</h3>
      >
      > <div id="myAutoComplete">
      > <input id="myInput" type="text">
      > <div id="myContainer"></div>
      > </div>
      >
      > <script type="text/javascript">
      > YAHOO.example.BasicRemote = function() {
      > // Use an XHRDataSource
      > alert("in function");
      > var oDS = new
      > YAHOO.util.XHRDataSource("http://10.129.203.40:8080/newproject/getautocompleteData.jsp");
      > // Set the responseType
      > alert("oDS.responseType");
      > oDS.responseType = YAHOO.util.XHRDataSource.TYPE_TEXT;
      > // Define the schema of the delimited results
      > alert("oDS.responseSchema");
      > oDS.responseSchema = {
      > recordDelim: "|",
      > fieldDelim: ","
      > };
      > // Enable caching
      > oDS.maxCacheEntries = 5;
      > alert("oDS.maxCacheEntries");
      > // Instantiate the AutoComplete
      > var oAC = new YAHOO.widget.AutoComplete("myInput", "myContainer", oDS);
      > alert(oAC);
      >
      > oAC.generateRequest = function(sQuery)
      > {
      > var val = document.getElementById("myInput").value;
      > alert("val="+val);
      > return "?query=" + sQuery;
      > };
      > alert("after generateRequest");
      > return {
      > oDS: oDS,
      > oAC: oAC
      > };
      > //alert("last line");
      > }();
      > </script>
      >
      > <!--END SOURCE CODE FOR EXAMPLE =============================== -->
      >
      > </body>
      > </html>
      > ----------
      >
      >
      > It works fine on Internet Explorer. I know the reason that Mozilla's
      > security model throws an exception when the request comes from a different
      > port or URL. ... How do I solve this.
      >
      > I am using a JSP script for server side.
      >
      > -----------------------------
      >
      > <%@ page language = "java" %>
      > <%@ page import = "java.sql.*" %>
      > <%@ page import = "java.util.*" %>
      > <%@ page import = "java.io.*" %>
      > <%@ page import="java.lang.*" %>
      >
      > <%
      > Connection connection ;
      > Statement s;
      > ResultSet rs = null;//resultset to get the count of the selected operation.
      > String strval = request.getParameter("query").trim();
      > String rsval = "";
      > String outputval = "";
      > String sqlstr = "";
      > try
      > {
      > Class.forName("com.mysql.jdbc.Driver").newInstance();
      > connection = DriverManager.getConnection("jdbc:mysql://
      > 10.129.203.121:3306/farmer_db2","root","secret");
      > s = connection.createStatement();
      >
      > sqlstr = "SELECT * FROM `sms_master` WHERE message like %'" + strval +
      > "%'";
      > //sqlstr = " SELECT * FROM sms_master limit 0,10" where language like '"
      > + strval + "'";
      > rs = s.executeQuery(sqlstr);//execute the query.
      >
      > //out.println("in ops=1"+sqlstr);
      > rs.last();
      > int cnt = rs.getRow();
      > int i = 1;
      >
      > //create string
      > rs.first();
      > while ( rs.next())
      > {
      > //out.println("<br>i="+i + "cnt="+cnt + "<br>");
      > if ( i == 1 )
      > {
      > outputval = outputval +
      > String.valueOf(rs.getInt("sms_id")).trim() + "," +
      > rs.getString("expected_date").trim() + "|";
      > //out.println("if part");
      > }
      > else if ( i == (cnt-1) )
      > {
      > outputval = outputval +
      > String.valueOf(rs.getInt("sms_id")).trim() + "," +
      > rs.getString("expected_date").trim() ;
      > //out.println("else part");
      > }
      > else
      > {
      > outputval = outputval +
      > String.valueOf(rs.getInt("sms_id")).trim() + "," +
      > rs.getString("expected_date").trim() + "|" ;
      > //out.println("else part");
      > }
      > //out.println("<br>"+"i="+i + "outputval="+outputval+ "cnt="+ cnt
      > +"<br>");
      >
      > i++;
      > }
      >
      > out.println(outputval);
      > //out.println("<br> final string="+outputval);
      >
      > //out.println("Hindi,01|English,02|Hindi,03|English,04|Hindi,05|English,06");
      > //out.print("Hello1 \t Test1 \n");
      > //out.print("Hello2 \t Test2 \n");
      > //return outputval;
      > //rs.close();
      > //s.close();
      > //connection = null;
      > }
      > catch (ClassNotFoundException e)
      > {
      > out.println(" \n ConnectionBean: driver unavailable" + e );
      > e.printStackTrace();
      > //connection = null;
      > }
      > catch (SQLException sqle)
      > {
      > out.println(" \n SQL Exception->ConnectionBean: driver not loaded");
      > sqle.printStackTrace();
      > //connection = null;
      > }
      > catch (NullPointerException e1)
      > {
      > out.println(" \n ConnectionBean: Null Pointer"+e1);
      > e1.printStackTrace();
      > //connection = null;
      > }
      >
      >
      > %>
      > ----------------------------
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.