File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes Getting error while posting HTTPS POST method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Getting error while posting HTTPS POST method" Watch "Getting error while posting HTTPS POST method" New topic
Author

Getting error while posting HTTPS POST method

Abhijit Kumbhar
Greenhorn

Joined: Dec 28, 2010
Posts: 2
Hi Every1,
I am getting error while posting post request in html.

The error is.
***************************************
POST
Resp Code:405
Resp Message:Method not allowed

***************************************
I am using Https IIS server. if you knows about this then please suggest me.. condition is i can,t use another server (specification)

Regards,
Abhijit


PLEASE VIEW CODE ALSO IF POSSIBLE..

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package com.https;

import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.net.ssl.HttpsURLConnection;

/**
*
* @author Administrator
*/
public class MyHttpsPOSTClass
{
public static void main(String args[])
{
try
{
URL url = new URL("https://localhost/a.pdf");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod("POST");
System.out.println(connection.getRequestMethod());
HttpsURLConnection.setFollowRedirects(true);
int i;
FileInputStream fin = new FileInputStream("C://Https Download/anyfile.txt");
DataOutputStream output = new DataOutputStream( connection.getOutputStream() );
do
{
i = fin.read();
if (i != -1)
output.writeInt(i);
}while (i != -1);
output.close();

fin.close();

System.out.println("Resp Code:"+connection.getResponseCode());
System.out.println("Resp Message:"+ connection.getResponseMessage());

} catch (Exception ex)
{
System.out.println(ex);
}
}
}


Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Abhijit Kumbhar wrote:
The error is.
***************************************
POST
Resp Code:405
Resp Message:Method not allowed



Error code 405 means that the access method is not allowed -- exactly described in the error message. This means that your web server is not allowing post requests. You need to change the configuration on your web server to allow post requests.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Abhijit Kumbhar
Greenhorn

Joined: Dec 28, 2010
Posts: 2
Hi all and Henry,
My IIS 5.1 HTTPS Server not responding POST method after setting its GET,POST verb in (Default Website>Configuration>set POST ,GET etc.)
If any one know about this error then suggest me once.

Regards
Abhijit
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting error while posting HTTPS POST method