Results 1 to 2 of 2
  1. #1
    navishkumarb is offline Member
    Join Date
    Dec 2007
    Posts
    2
    Rep Power
    0

    Default java.io.Exception: Server returned HTTP response code: 403

    hi can anyone tell me what might be the error in the following code(this is only the part of my code where the error is occuring )

    Properties systemSettings = System.getProperties();
    systemSettings.put("http.proxyHost","132.147.160.1 ");
    systemSettings.put("http.proxyPort", "8084");
    String record = null;
    FileReadTest f = new FileReadTest();

    /*opening the text document*/
    try{
    File fi = new File("gi2.txt");
    FileInputStream fis = new FileInputStream(fi);
    BufferedInputStream bis = new BufferedInputStream(fis);
    DataInputStream dis = new DataInputStream(bis);

    while ( (record=dis.readLine()) != null )
    {
    /*url connection*/

    URL url=new URL("http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?db=protein&c_start=1&uids="record"&dop t=fasta&dispmax=1&sendto=t&from=begin&to =end&page=1");
    HttpURLConnection urlConn = (HttpURLConnection)url.openConnection();
    urlConn.setRequestProperty("User-agent","Mozilla/2.0.0.11");
    urlConn.connect();

    /*creating a text file*/
    File create = new File(record+".txt");
    try
    {
    if(!create.exists())
    {
    create.createNewFile();
    }
    else
    {
    System.out.println("file already exists");
    }
    }
    catch(IOException e)
    {
    System.err.println("cannot create a file");
    }


    it was returning me the following error
    java.io.Exception: Server returned HTTP response code: 403 for URL: http://www.ncbi.nlm.nih.gov/entrez/v...o= end&page=1
    at sun.net.www.protocol.http.HttpURLConnection.getInp utStream<HttpURLConnection.java.704>
    at eutils.main(eutils.java:136)

  2. #2
    maruthi_s is offline Member
    Join Date
    Jan 2008
    Posts
    20
    Rep Power
    0

    Default

    Hey the way you gave the URL is wrong, when you declare a java syntax you should be very careful. The one bolded in has caused the bug :). You did not use a escape sequence to understand the ".

    ("http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?db=protein&c_start=1&uids="record"&dop t=fasta&dispmax=1&sendto=t&from=begin&to =end&page=1");

Similar Threads

  1. Server returned HTTP response code: 500.. i need help
    By hardc0d3r in forum Java Servlet
    Replies: 9
    Last Post: 03-12-2012, 09:08 PM
  2. java code for send sms through http
    By for108 in forum Java Servlet
    Replies: 11
    Last Post: 09-24-2009, 11:22 AM
  3. Replies: 1
    Last Post: 03-08-2008, 07:41 PM
  4. response.sendRedirect(url)
    By mutuah in forum Advanced Java
    Replies: 2
    Last Post: 08-07-2007, 02:56 PM
  5. Server returned HTTP response code: 500
    By Heather in forum Java Servlet
    Replies: 1
    Last Post: 07-09-2007, 05:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •