Jul 20, 2008

Http Method Post Is Not Supported By This Url

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > Java, Java Servlets, Java Script, & JSP

free web hosting

Http Method Post Is Not Supported By This Url

kvarnerexpress
hi ,
i wrote an html file
....
<form name="Post your reminders here"
method="POST"
action="http://localhost:8080/examples/servlet/request">
....
and the request.java is
import java.io.*;
import javax.servlet.*;
import java.sql.*;
import java.text.*;
import java.util.*;
import javax.servlet.http.*;

public class request extends HttpServlet
{
public String getServletInfo()
{
return " Servlet connect to database and show the result of a SELECT";
}
private Connection dbcon;
public void init(ServletConfig config) throws ServletException
{
String loginUser="postgres";
String loginPasswd="postgres";
String loginUrl="jdbcostgresql://localhost/remind";
try
{
Class.forName("org.postgresql.Driver");
dbcon=DriverManager.getConnection(loginUrl,loginUser,loginPasswd);
}
catch (ClassNotFoundException ex)
{
System.err.println("ClassNotFoundException:"+ex.getMessage());
throw new ServletException("Class not found Error");
}
catch(SQLException ex)
{
System.err.println("SQLException:"+ex.getMessage());
}

}
public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException
{
response.setContentType("text/html");
PrintWriter out=response.getWriter();
out.println("<HTML><Head><Title>REQUEST</Title></Head>");
out.println("<Body><H1>REQUEST</H1>");
try
{
Statement statement=dbcon.createStatement();

String query="SELECT * FROM remind";
ResultSet rs=statement.executeQuery(query);
out.println("<TABLE border>");
while(rs.next())
{
String m_name=rs.getString("name");
String m_time=rs.getString("time");
String m_subject=rs.getString("subject");
out.println("<tr>"+
"<td>"+m_name+"</td>"+
"<td>"+m_time+"</td>"+
"<td>"+m_subject+"</td>"+
"</tr>");
}
out.println("</TABLE></Body><HTML>");
statement.close();
}
catch(Exception ex)
{
out.println("<HTML>" +
"<Head><Title>" +
"remind:Error" +
"</Title></Head>\n<Body>"+
"<P>SQL error in doGet:" +
ex.getMessage() +"</P></Body></HTML>");
return;
}
out.close();
}
}
the database is in postgresql
now when i access the html file i get the error

HTTP method POST is not supported by this URL
could somebody help me?

 

 

 


Reply

OpaQue
Hmm.. Strange error "Http Method Post Is Not Supported By This Url"

Did you pass the appropriate headers. When you process files in server side scripting language you have to tell the browser what type of file is being returned.

If you did, then I would recommend that you use FLUSH() type of functions and break the output so as to figure out what is causing that error.

Reply

VoLai
It is most likely because of your servlet engine configuration or your servlet configuration.

I have seen this error before on a shared host, when I tried to invoke a JSP page. However, after some months, when I tried again, it worked perfectly.

One solution for you is:
Write another method in to your servlet like this:

public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException
{

doPost(request, response);

}

After that, change the HTML file to
<form name="Post your reminders here"
method="GET"
action="http://localhost:8080/examples/servlet/request">

to see if it works.

If it works, please check your server configuration to see if it forbids certain POST from certain context.

Reply

cse-icons
yes, u can override doGet and call doPost from there.

But the reason for the problem might be that ur context configuration file might have been configured to block POST requests.

Check ur context web.xml file or server.xml file in the server(in case of tomcat).

Cheers.

Reply

iGuest
page is not opening
Http Method Post Is Not Supported By This Url

Sir
when I access my account in BSNL broad band (india)
error is coming like
"HTTP method GET is not supported by this URL"
will you please
help me in coming out of this error

thanks



-reply by vishal

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. http method post is not supported by this url servlet - 9.05 hr back. (1)
  2. http method post is not supported by this url jboss - 17.22 hr back. (1)
  3. jsonrpcclientexception: http method post is not supported by this url - 23.11 hr back. (1)
  4. http method get is not supported by this url servlet solution - 34.27 hr back. (1)
  5. servlet method post is not supported by this url - 39.19 hr back. (1)
  6. error: http method post is not supported by this url - 46.94 hr back. (1)
  7. http method post is not supported by this url - 14.21 hr back. (2)
Similar Topics

Keywords : http, method, post, supported, url

  1. What Java Open Source Packages Are Supported Here?
    Java Open Source (0)


      Looking for http, method, post, supported, url

Searching Video's for http, method, post, supported, url
advertisement



Http Method Post Is Not Supported By This Url



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE