Nov 21, 2009

Http Method Post Is Not Supported By This Url

free web hosting
Open Discussion > MODERATED AREA > Computers > Programming Languages > Java, Java Servlets, Java Script, & JSP

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?

 

 

 


Comment/Reply (w/o sign-up)

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.

Comment/Reply (w/o sign-up)

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.

Comment/Reply (w/o sign-up)

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.

Comment/Reply (w/o sign-up)

FeedBacker
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

Comment/Reply (w/o sign-up)



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*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)


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


Http Method Post Is Not Supported By This Url

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com