Jump to content

Access to restricted URI denied error...!


centaur

Recommended Posts

I am using jetty server on my system to hold the server side scripts.I was using AJAX requests to get server response when I got the following error on Mozilla Firefox:Access to restricted URI denied" code: "1012I researched a bit on the internet and got to know that it occurs due to Firefox's security model that does not allow retrieving/accessing localhost resources.But I could not figure out how to get around this error. Is it possible to keep using the jetty server and get rid of this error?The java servlet that handles the client requests reside in a file structure as: dashboard/src/main/java/com/an/common/web/DashboardServlet.javaThe html page also resides on my local drive which further sends the request to the server.Can someone please address the issue and drop some hint in solving it?Thanks in advance..!! :) --Centaur

Link to comment
Share on other sites

It's JavaScript's security. It cannot access the clients filesystem when run from a server. If you want to access it you need to place it on your web server and give your JavaScript the address of it. For example URL = localhost/file.txt. This was written on a wobbly bus on my phone. Sorry if there are mistakes.

Link to comment
Share on other sites

It's JavaScript's security. It cannot access the clients filesystem when run from a server. If you want to access it you need to place it on your web server and give your JavaScript the address of it. For example URL = localhost/file.txt. This was written on a wobbly bus on my phone. Sorry if there are mistakes.
Do you mean that I should modify:req.open("POST","response1.xml",true);toreq.open("POST","localhost/dashboard/response1.xml",true);??I am working on Eclipse and have placed all the server side scripts/codes/files under the project created in Eclipse itself. Is that right as well?
Link to comment
Share on other sites

yeah, that looks right. AJAX can only access files from the webroot on the same domain, so putting it there should solve your problem.

Link to comment
Share on other sites

yeah, that looks right. AJAX can only access files from the webroot on the same domain, so putting it there should solve your problem.
I tried using it, bit it doesnt seem to solve my problem. Is there some other mistake that I might be making?? :) Can I also go wrong in specifying the html <form action = ""> attribute??As in, I have written it as <form method="post" action="http://localhost:8080/" enctype="multipart/form-data">The file having the servlet code is stored in further subfolders on the Eclipse project that I created. Should I specify the absolute path of the servlet on the server in the form action tag? And then in the javascript, specify the path of the file to be requested from the server(as told by you)?--Centaur
Link to comment
Share on other sites

well you need to specify an actual page/script the resides on your domain that is accessible from the web root. Localhost is not that (it's the root). You don't need to include the domain in the file path, just from the root. (thus making it relative).

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...