Jump to content
xisto Community
Sign in to follow this  
kvarnerexpress

Http Method Post Is Not Supported By This Url

Recommended Posts

hi ,i wrote an html file....<form name="Post your reminders here"method="POST"action="http://forums.xisto.com/no_longer_exists/ the request.java isimport 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 postgresqlnow when i access the html file i get the errorHTTP method POST is not supported by this URLcould somebody help me?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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://forums.xisto.com/no_longer_exists/ see if it works.If it works, please check your server configuration to see if it forbids certain POST from certain context.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.