Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTTP Response code 414

 
khan ahamad
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Could some one help me out here,I am getting 414 Request error -URI too long ,The Server is refusing to service the request because the requested URI is too long.Can I know how can can I overcome this error?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you submitting a form with method="get" or no method attribute?
If so, the browser will try to put the entire contents of the form in the querystring.
 
khan ahamad
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no method(get/post) attribute,I am using
HttpURLConnection httpConn = (HttpURLConnection) ((new URL(url).openConnection())); in order to go to that url.and the server is is refusing to service the request because the requested URL is too long and our HTTP server can take upto 8KB.
[ March 13, 2008: Message edited by: khan ahamad ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is your URL so long?
Are you building up a huge query string?
If so, why not create an HTTP Post request and send the data as part of the request body?
 
khan ahamad
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes the url is too long..I am not using IE to make the URL call, but I am making an HttpURLConnection with our Java code.So is it possible to use POST method in this case?
[ March 14, 2008: Message edited by: khan ahamad ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by khan ahamad:
... So is it possible to use POST method in this case?


Yes, there is a code sample that does just that in this thread:
http://www.coderanch.com/t/278906/Streams/java/HTTP-POST-does-vanilla-web
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by khan ahamad:
(...snip...)So is it possible to use POST method in this case?


Yes, and in general POST method is to be preferred over GET because of not exposing session data to uninfomed users. I am working on something very close to this right now and have a design idea of a few name=value pairs in the address-bar, but not much and nothing along the lines of url-encoding that ends up with many %20%20 and so on in the request string.
 
khan ahamad
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can the other solution to this problem be splliting up the calls
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will have to code 'split the calls' - I am sure you intend to write name/value pairs in the viewable url. An attempt to code this will tell us what approach you are considering.
 
khan ahamad
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, I dont mind displaying name/value in url
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What don't you want to send the data in the body with the post method?
That sounds like the easiest and most stable way to do this.
 
khan ahamad
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I implemented post method but still I am getting the same error HTTP 414, I am not able to make out why that is happening
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
khan ahamad
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
URL is exceeding 8K and the server which accepts this URL has 8K limit.
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What package are you using?
 
khan ahamad
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HttpURLConnection httpConn = (HttpURLConnection) ((new URL(URL).openConnection()));
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're sending the data in a post string, the URL should no longer need to be very large.
 
khan ahamad
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes , As I am sending data in post method I am splitting the URL
URL=actual url without parameter(that is upto "?" mark)
URLParam=URl's parameter (that is (name=value)

HttpURLConnection httpConn = (HttpURLConnection) ((new URL(URL).openConnection()));
httpConn.setRequestMethod("POST");
httpConn.setDoOutput(true);
OutputStream os = con.getOutputStream();
httpConn.setRequestProperty(URLParam.length());
httpConn.connect();
 
khan ahamad
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please can anyone help me?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're sending the data in the post, you shouldn't need a '?' symbol or any name=value pairs in your URL.

What does your URL look like?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic