Error 403 Reported when trying to access web page through a program.

I was writing a program for fun, to try to download a web page, pdf or anything from the web. The program works fine when given local file system path in URL and also works well when i tried to access a page from the tomcat installed on my machine but gives a error 403 when tried to access URL's outside the system. Tried to read about 403, seems that many sites does not allow to access a particular URL directly using the directory structure, you have to pass thru different hyperlinks before reaching resource.
IS THERE ANY WAY THIS PROBLEM CAN BE SOLVED.
import java.io.*;
import java.net.*;
class TestDownload
     public static void main(String[] args)
          try
               URL url = new URL("http://www.webmasterworld.com/forum48/1966.htm");
          //     URL url = new URL("http://localhost:8080/index.html");
          //     URL url = new URL("file:\\C:\\web_2.pdf");
               URLConnection connection = url.openConnection();
               InputStream stream = connection.getInputStream();
               BufferedInputStream in = new BufferedInputStream(stream);
               FileOutputStream file = new FileOutputStream("x.html");
               BufferedOutputStream out = new BufferedOutputStream(file);
               int i;
               while ((i = in.read()) != -1) {
                    out.write(i);
               out.flush();
          catch(IOException e)
               e.printStackTrace();
          System.out.println("Hello World!");
}

I was writing a program for fun, to try to download a web page, pdf or anything from the web. The program works fine when given local file system path in URL and also works well when i tried to access a page from the tomcat installed on my machine but gives a error 403 when tried to access URL's outside the system. Tried to read about 403, seems that many sites does not allow to access a particular URL directly using the directory structure, you have to pass thru different hyperlinks before reaching resource.
IS THERE ANY WAY THIS PROBLEM CAN BE SOLVED.
import java.io.*;
import java.net.*;
class TestDownload
     public static void main(String[] args)
          try
               URL url = new URL("http://www.webmasterworld.com/forum48/1966.htm");
          //     URL url = new URL("http://localhost:8080/index.html");
          //     URL url = new URL("file:\\C:\\web_2.pdf");
               URLConnection connection = url.openConnection();
               InputStream stream = connection.getInputStream();
               BufferedInputStream in = new BufferedInputStream(stream);
               FileOutputStream file = new FileOutputStream("x.html");
               BufferedOutputStream out = new BufferedOutputStream(file);
               int i;
               while ((i = in.read()) != -1) {
                    out.write(i);
               out.flush();
          catch(IOException e)
               e.printStackTrace();
          System.out.println("Hello World!");
}

Similar Messages

  • Just recently I am getting the following error message when trying to access web sites. I get a pop up window stating "Exc in ev handl: TypeError: c.location is null" then I have to click ok. It is an issue with some plug-in?

    Just recently I am getting the following error message when trying to access web sites. I am using Firefox browser version 10.0.2. I get a pop up window stating "Exc in ev handl: TypeError: c.location is null" as the web site page is being displayed in browser winder. Then I have to click ok. It doesn't matter what web link/site I go to it happens. It is an issue with some plug-in?

    I have advised McAfee's product team of the problem and this thread, and they're looking into it now.

  • Error when trying to access a form through https

    Hi,
    I'm facing this error when trying to access a form through https, i'm using OAS10g 10.1.2.3 over linux, it has webutil configured and is working perfectly with https
    I'm accessing the form through webcache.
    the error:
    Java Plug-in 1.6.0_37
    Usar versión JRE 1.6.0_37-b06 Java HotSpot(TM) Client VM
    Directorio local del usuario = C:\Users\Carlos
    c:   borrar ventana de consola
    f:   finalizar objetos en la cola de finalización
    g:   liberación de recursos
    h:   presentar este mensaje de ayuda
    l:   volcar lista del cargador de clases
    m:   imprimir sintaxis de memoria
    o:   activar registro
    q:   ocultar consola
    r:   recargar configuración de norma
    s:   volcar propiedades del sistema y de despliegue
    t:   volcar lista de subprocesos
    v:   volcar pila de subprocesos
    x:   borrar antememoria del cargador de clases
    0-5: establecer nivel de rastreo en <n>
    cargar: clase oracle.forms.webutil.common.RegisterWebUtil no encontrada.
    java.lang.ClassNotFoundException: oracle.forms.webutil.common.RegisterWebUtil
         at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Excepción: java.lang.ClassNotFoundException: oracle.forms.webutil.common.RegisterWebUtil
    cargar: clase oracle.forms.engine.Main no encontrada.
    java.lang.ClassNotFoundException: oracle.forms.engine.Main
         at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Excepción: java.lang.ClassNotFoundException: oracle.forms.engine.Mainwhat could be the reason it can not find the webutil libraries with https ?? i tried erasing the java's cache but still the same error :(
    Regards
    Carlos

    I got it, i only had to check the option 'Use SSL 2.0 compatible ClientHello format' from the java's control panel advanced tab.
    Metalink's note: 787739.1
    :)

  • Suddenly, *only with Firefox* all computers in the house show (Error code: ssl_error_rx_record_too_long) when trying to access any Google product.

    Today, all laptops in the house (latest ver of FF) began throwing the error:
    (Error code: ssl_error_rx_record_too_long)
    When trying to access any Google products: gmail, Google+, analytics, Google website, etc

    Aha! I'm in South Surrey, BC. I've got a call into a Shaw tech.

  • FireFox keep saying "unexpected error" when trying to print web pages.

    FireFox keep saying "unexpected error" when trying to print web pages. The print preview works OK, but when you try to print that "unexpected error" jumps up.
    Please email me on what to do to get FireFox to work.
    I don't see anything in the FAQ that might help me.

    Hi,
    Please also try this setting: Windows start menu or Control Panel > '''Devices and Printers''', right-click the printer > '''Printer properties''' > '''Advanced''', and select '''Start printing after the last page is spooled'''. In this case you can also close Firefox after spooling is over (usually much faster than direct printing), and printing will continue.
    Also as a general case, if you have security software (antivirus, firewall etc.) installed, you can try deleting all existing instances of Firefox and its related processes/files in all the different configuration modules/areas of the security software like process monitoring, sub/spawned process control, virtualization, HIPS etc., in addition to the security software's main configuration panel. Instead create new fully allowed/trusted rules for Firefox + its related processes in all the different modules/panels - a genuine/original Firefox installer as well as all the installed EXEs (Application) and DLLs (Application extension) are digitally signed by Mozilla Corporation (right-click > Properties > Digital Signatures). Even otherwise, some security software may also ask again when Firefox and/or its sub processes are started, and you may be able to allow/trust at that time. Please see [https://support.mozilla.org/en-US/kb/Firewalls this].
    [http://kb.mozillazine.org/Firewalls AV/Firewalls Configuration]

  • I get scrip error when trying to print web pages.

    I get a scrip error message when trying to print web pages and it will not print.

    FreddieP,
    You may want to download and run the HP Print and Scan Doctor. It helps diagnose and resolve printing issues. You can click on the link below to go right to it.
    Let us know if this works for your issue or not.
    http://h10025.www1.hp.com/ewfrf/wc/softwareDownloadIndex?softwareitem=oj-106151-2&cc=us&dlc=en&lc=en...
    If I helped you at all it would be great if you clicked the blue kudos star!
    If I solved your post please mark it as solved to help others.
    I'm a printer tech with HP.

  • Have published iweb site for five years with no problems and just opened a new site and get - 404: Page not found  This error is generated when there was no web page with the name you specified at the web site.-is the problem with iweb or with hosting?  T

    I am sorry if thie is republished-My first time doing this and I am not sure what goes where and where to hear feedback.
    Have published iweb site for five years with no problems and just opened a new site and get -
    404: Page not found 
    This error is generated when there was no web page with the name you specified at the web site.-
    Troubleshooting suggestions:
    Ensure the page you are linking to exists in the correct folder.
    Check your file name for case sensitivity . Index.htm is not the same as index.htm!
    Temporarily disable any rewrite rules by renaming your .htaccess file if it exists
    is the problem with
    iweb or with hosting?
    One Apple tech started to fix Iweb and had to end session and the next said problem with hosting at Network Solutions as it published
    to local folder. NWS has checked sttting a few times-
    Any help would be extremely appreciated as trying to fix this for about five weeks
    Thanks VG
    <Email Edited by Host>

    It's a really bad idea to post your email address - it's an invitation to spam - and I've asked the Hosts to remove it. (Even though I've now noticed you mis-spelled it! - anyway, never post your address in a forum.)
    You have a site here: http://virginiagordon.com/www.virginiagordon.com/WELCOME.html
    If that's not the page you are having trouble with, what is that page's URL?

  • CS6: DistributedCOM Error id: 10016 when open pdf from web page in Win8.1

    For example here below I've got the issue: 
    http://modemwifi.it/wp-content/uploads/asus-dsl-n55u.pdf
    Adobe Acrobat X pro V 10.1.8:
    DistributedCOM Error id: 10016 when open pdf from web page.
    Nome registro: System
    Origine:       Microsoft-Windows-DistributedCOM
    Data:          04/11/2013 19:09:19
    ID evento:     10016
    Categoria attività:Nessuna
    Livello:       Errore
    Parole chiave: Classico
    Utente:        PC-PIERO\Piero
    Computer:      Pc-Piero
    Descrizione:
    Le impostazioni delle autorizzazioni impostazioni predefinite del computer non concedono l'autorizzazione di Attivazione in Locale per l'applicazione server COM con CLSID
    {B801CA65-A1FC-11D0-85AD-444553540000}
    e APPID
    {2EAF0840-690A-101B-9CA8-9240CE2738AE}
    all'utente Pc-Piero\SID Piero (S-1-5-21-3453328585-262132574-2759341577-1001) dall'indirizzo LocalHost (tramite LRPC) in esecuzione nel SID del contenitore di applicazioni Non disponibile (S-1-15-2-1430448594-2639229838-973813799-439329657-1197984847-4069167804-1277922394). Per modificare tale autorizzazione di sicurezza, è possibile utilizzare lo strumento amministrativo Servizi componenti.
    XML evento:
    < Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
      <System>
        <Provider Name="Microsoft-Windows-DistributedCOM" Guid="{1B562E86-B7AA-4131-BADC-B6F3A001407E}" EventSourceName="DCOM" />
        <EventID Qualifiers="0">10016</EventID>
        <Version>0</Version>
        <Level>2</Level>
        <Task>0</Task>
        <Opcode>0</Opcode>
        <Keywords>0x8080000000000000</Keywords>
        <TimeCreated SystemTime="2013-11-04T18:09:19.468877700Z" />
        <EventRecordID>14806</EventRecordID>
        <Correlation />
        <Execution ProcessID="768" ThreadID="776" />
        <Channel>System</Channel>
        <Computer>Pc-Piero</Computer>
        <Security UserID="S-1-5-21-3453328585-262132574-2759341577-1001" />
      </System>
      <EventData>
        <Data Name="param1">impostazioni predefinite del computer</Data>
        <Data Name="param2">Locale</Data>
        <Data Name="param3">Attivazione</Data>
        <Data Name="param4">{B801CA65-A1FC-11D0-85AD-444553540000}</Data>
        <Data Name="param5">{2EAF0840-690A-101B-9CA8-9240CE2738AE}</Data>
        <Data Name="param6">Pc-Piero</Data>
        <Data Name="param7">Piero</Data>
        <Data Name="param8">S-1-5-21-3453328585-262132574-2759341577-1001</Data>
        <Data Name="param9">LocalHost (tramite LRPC)</Data>
        <Data Name="param10">Non disponibile</Data>
        <Data Name="param11">S-1-15-2-1430448594-2639229838-973813799-439329657-1197984847-4069167804-1 277922394</Data>
      </EventData>
    < /Event>
    How can I solve this problem?
    Thanks

    // I got this from an Action (I�m using Struts)
    java.sql.Blob file=(java.sql.Blob)request.getAttribute("PDFfile");
    String filename=(String)request.getAttribute("filename");
    try{
      int iLength = (int)(file.length());
      response.setHeader("Content-type", "application/pdf");   
      response.setHeader("Content-Disposition", "inline; filename=\""+filename+"\"");
      response.setHeader("Expires","0");
      response.setHeader("Cache-Control","must-revalidate, post-check=0, pre-check=0");
      response.setHeader("Pragma","public");
      response.setContentLength(iLength);
      ServletOutputStream os = response.getOutputStream();
      InputStream in = null;
      in = file.getBinaryStream();
      byte buff[] = new byte[1024];
      while (true) {
          int i = in.read(buff);
          if (i<0) break;      
          os.write(buff,0,i); 
      os.flush();
      os.close();
    } catch(Exception ex){
       out.println("Error while reading file : " + ex.getMessage());
    }and now it�s running !!! I�m not using response.setContentType(...) and I do this in response.setHeader("Content-type", "application/pdf"). And I use response.setHeader("Content-Disposition", "inline; filename=\""+filename+"\"") instead of response.setHeader("Content-Disposition", "attachment; filename=\""+filename+"\"");

  • Fix for "Not Connected" Error Messages When Trying to Access Web Services

    If you run across an error message on your printer stating that it is "Not Connected" when trying to access ePrint or your Apps, but you know it is connected to the internet, it probably just means that the printer is not connecting to the server properly.
    Here is the first set of steps I would try, since they seem to resolve this issue half of the time.
    The first thing I would try in this situation is a network reboot.
    First, disconnect the power cord from the back of your router. 
    Next disconnect the power cord from either the back of the printer or the wall, without powering it off first. 
    Wait about 30 seconds and reconnect the power cord to your router.
    Wait about another 30 seconds and plug the printer back in. It should boot back up automatically, but if it doesn't go ahead and press the power button.
    Once everything is back up and running, try to access ePrint or your Apps.
    If those steps don't work for you, the next thing would be setting a Static IP & DNS for the printer. Before doing this, you want to print off a network configuration page. It varies from model to model, but it is usually found under the Wireless Settings or under Reports in the Setup menu. After you have that page, follow these steps.
    Before we start, we need a network configuration page with your current connection settings. To get this, press the wireless button on the front of your printer and then press "Print Info" or "Print Report". This will print off a network configuration page, which has information on it that we need to complete the next few steps.
    After you have that, we will need to access the printers Embedded Web Server (EWS). You can do so by entering the printers IP address (from the network configuration page) into your browsers address bar and pressing enter.
    Once there, press the "Network" tab at the top of the page. From there you will want to click the "IPv4" button, located on the lef-hand side of the page. It will be there for WIreless and Wired, so make sure to click the one for you however you are connected. If you do not see "IPv4", you should see "Networking", press that and then press "Network Address(IP)".
    Next, you will want to click the small round button next to "Manual IP Address" and then fill in the boxes for IP Address, Subnet Mask, and Default Gateway, using the information found on the network configuration page.  
    For the Primary or Preffered DNS Server, you will want to enter 8.8.8.8.
    For the Secondary or Alternate DNS Server, you will want to enter 8.8.4.4.
    Click apply and when the message pops up saying that the changes have been applied, press "OK". 
    Press the power button on your printer, wait for it to fully power off and then press it again to power it back on.
    After doing this, go ahead and try to enable ePrint again.
    -------------How do I give Kudos? | How do I mark a post as Solved? --------------------------------------------------------
    This question was solved.
    View Solution.

    The reason we recommend using 8.8.8.8 and 8.8.4.4 for the DNS server is because they work when ISP assigned DNS servers do not. The DNS server assigned to you by your ISP is not able to resolve the domain for web services, therefore not allowing the printer to connect. 
    I assure you that it is with your ISP's DNS server and not the printer. If you were to take the printer back to the store and get a replacement, you would have the same issue, unless you changed the DNS. Same goes for any of our web service enabled printers. 
    -------------How do I give Kudos? | How do I mark a post as Solved? --------------------------------------------------------

  • Why do I keep getting this 500: Server Error [20-0004] when trying to access Bell mobility?

    When trying to access Bell Mobility account I get 500: Server Error [20-0004].  Is this a problem with my mac or their server?

    Have you tried on another device?
    The folow sugests it is a server issue (not your computer)( but give several actions to confirm that.
    http://pcsupport.about.com/od/findbyerrormessage/a/500servererror.htm

  • Error code 0x80092013 when trying to access iTunes store

    I currently have the lastest version of iTunes unstalled on a Windows Vista PC. For a few months now, I get the error code 0x80092013 when trying to connect to the iTunes store or log in to my iTunes account. I have tried to run diagnostics but there is no help availavle because iTunes will not connect to the internet to get the help I need.
    I have scoured the interent for a solution to this problem and have tried everything I have come accross, from re-installing to reading every support page I can find. I am becoming so frustrated trying to fix this problem, it is not my apple ID as my iPad works perfectly fine. If anyone can give me a solution that actually works it would be greatley appreciated

    After some research I found the following tip to be working:
    https://discussions.apple.com/message/25038447#25038447
    So I changed my IPv4 as well as IPv6 DNS-Servers under Windows Network Preferences and everything worked again.
    HTH
    Christian

  • Event 6-303014 Syn TimeOut when trying to access a page on Internet

    Hello. I have a ASA 5540 (8.4) as an Internet Firewall.
    When trying to navigate on Internet through ASA I can do it without problem except one page.
    Page is accessible if I navigate without ASA Firewall (for example home Internet)
    Reviewing firewall logs, event 6-303014 Syn TimeOut appears everytime I Try to access it.
    This page works on port 80.
    Thank you in advance for your advice.
    Regards
    Fernando

    Do you see a "3G", "E", or "o" next to the carrier name and signal indicator on the phone? If not, then you are not connected to a cellular data network at all. It's not impossible that you're not in range of their data network. Who is your carrier and where are you located?
    If you do see one of those, you may want to call them again and ask explicitly to have them check the provisioning on your account.  Just because it looks right in the billing system does NOT mean they have it set up correctly.

  • Some users hitting error page when trying to access Web Applications...why?

    Hi,
    I have a SharePoint 2010 setup with 4 WFE, 4 APP Servers and 1 DB Server.
    After reading up a while back which services should be running on which server layer I remove the Web Application Service from APP Server (using Central Admin). The service is currently in error state on that machine. I had also removed a WFE Server which
    was not required and ensured all WFE had Web Application Service running as Microsoft Specified. I have checked each WFE and they have all same Web Applications in IIS. I have accessed a specific Web Application (that a user said they couldn't access) on 2
    of the 3 WFE servers when remoted into them, but one prompts me for login details. I have looked at the NLB on each WFE Server and saw that 2 out of three servers had all three servers in cluster. One that didn't was not same server as had problems accessing
    Web Application. I have removed a Server from Cluster and added it back as I saw Priorities were 1,2,4 (3 must have been initial removed server) and added it back again so Priorities were 1,2,3.
    Can anyone explain what may have happened in this scenario? It seems I think to be hitting this server with the problem accessing the Web Application. It seems to time out. How do I resolve this? DO I need to resync?
    Thanks.
    John.    

    Hi John,
    For your issue, it can be caused by that you remove  and  re-add a WFE from the NLB cluster. As  the Priority was changed, you need to disconnect and reconnect your SharePoint using SharePoint Products Configuration Wizard.
    Thanks,
    Eric
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Eric Tao
    TechNet Community Support

  • Error-36 when trying to access web disk

    I am trying to access a secure webdisk from my macbook pro to upload my webpage to a new hosting site, however every time i try to set up a connection with the acount i either encounter an "Error 36" message, a time out, or a message stating a connection time out.
    I can find alot of infomation as to how to format a hard drive to work using terminal, but nothing for this...
    Bit stumped, help would be appricated!!

    That's a network or server issue, not a problem with your Mac.

  • Error code 64 when trying to access a website

    I am trying to access my own photography website in Firefox (www.placesandseasons.com) on someone else's computer which still has Windows XP on it, & I get the error message below. Please note that there is no problem with the website host; I can access the site on both Chrome & IE on this computer, & also on Firefox on my Mac at home. I also used to be able to access it on Firefox on this Windows PC; this is a recent issue. I asked my website hosts & they said there is no issue at that end. Can anyone tell me what the problem is? Thanks.
    ERROR MESSAGE
    Explanation: The request timed out before the page could be retrieved.
    Technical Information (for support personnel)
    Error Code 64: Host not available
    Background: The gateway or proxy server lost connection to the Web server.
    Date: 27/08/2014 15:46:34 [GMT]
    Server: SRVLAW208.lawsociety.int
    Source: Remote server

    Could you review the connection setting on that computer?
    "3-bar" menu button (or Tools menu) > Options > Advanced > Network mini-tab > "Settings" button
    The default of "Use system proxy settings" should piggyback on IE/Windows' LAN settings. You could try "No proxy" to see whether that works any better.
    More generally: When you have a problem with one particular site, a good "first thing to try" is clearing your Firefox cache and deleting your saved cookies for the site.
    (1) Bypass Firefox's Cache
    Use Ctrl+Shift+r to reload the page fresh from the server.
    Alternately, you also can clear Firefox's cache completely using:
    "3-bar" menu button (or Tools menu) > Options > Advanced
    On the Network mini-tab > Cached Web Content : "Clear Now"
    If you have a large hard drive, this might take a few minutes.
    (2) Remove the site's cookies (save any pending work first). While viewing a page on the site (if you can load any page), try either:
    * right-click and choose View Page Info > Security > "View Cookies"
    * (menu bar) Tools > Page Info > Security > "View Cookies"
    In the dialog that opens, you can remove the site's cookies individually.
    ''If you can't load a page on the site, open the dialog here and then edit the search/filter box at the top of the dialog to the site you want to clean cookies for.''
    Then try reloading the page. Does that help?

Maybe you are looking for

  • HP 8600 Officejet Pro

    I have been having trouble lately getting the error that the printhead is missing and it also says there is a problem with the printer or ink system.  It give the troubleshooting tip to remove and then put it back in and turn the machine off and then

  • Holding of withholding tax in prepayment

    Dear All I have a clinent scenario which says that: We create a prepayment invoice and at the time of payin full we dont want to deduct withholding tax. We want it to be deducted when we create a standard invoice to knock off the prepayment. Can any

  • Where used of a table field in BI extraction program

    Hi, How can I find a particular table or table-field is used in any BI extraction program or not? Actually we are doing a modification and change in the structure of a big Z table and custom developments. So I want to analyse and list the programs re

  • Using External iSight camera instead of built-in with iMovie

    I have a MacBook Pro with built in iSight as well as an external iSight camera. I want to shoot some instructional knitting videos with the external camera, holding it over the shoulder of the knitting instructor while she discusses what she is doing

  • HOW TO KEEP CLIENT COPY

    Dear All, In Dev Server, we have 2 clients 400 & 500. In Client 400 all customization is done & also some master date is created, like material master, vendor master. 500 is a fresh client. Now i need to put a client copy of 400 to 500, with only cus