Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-27-2007, 07:27 AM
Member
 
Join Date: Dec 2007
Posts: 1
navishkumarb is on a distinguished road
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)
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-05-2008, 02:33 PM
Member
 
Join Date: Jan 2008
Posts: 20
maruthi_s is on a distinguished road
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");
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
java code for send sms through http for108 Java Servlet 2 04-02-2008 01:00 PM
Trouble with factory method - unhandled exception type Exception desmond5 New To Java 1 03-08-2008 07:41 PM
response.sendRedirect(url) mutuah Advanced Java 2 08-07-2007 02:56 PM
Server returned HTTP response code: 500.. i need help hardc0d3r Java Servlet 4 07-18-2007 03:43 PM
Server returned HTTP response code: 500 Heather Java Servlet 1 07-09-2007 05:32 AM


All times are GMT +3. The time now is 09:32 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org