Note that there are some explanatory texts on larger screens.

plurals
  1. POJava servlets - HTTP Status 405 - HTTP method GET/POST is not supported by this URL
    text
    copied!<p>I have created a form:</p> <pre><code> &lt;form method="post" action="new"&gt; &lt;input type="text" name="title" /&gt; &lt;input type="text" name="description" /&gt; &lt;input type="text" name="released" /&gt; &lt;input type="submit" value="Send" /&gt; &lt;/form&gt; </code></pre> <p>When I send this form, I will get following error:</p> <pre><code>HTTP Status 405 - HTTP method POST is not supported by this URL </code></pre> <p>I changed in the form <code>post</code> to <code>get</code>, but I got a similar error:</p> <p>Here's how look like the servlet:</p> <pre><code>import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; public class MyServlet extends HttpServlet { protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); String title = request.getParameter("title"); String description = request.getParameter("description"); String released_string = request.getParameter("released"); int released = Integer.parseInt(released_string); try { Class.forName("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql://localhost:8889/app_name", "username", "password"); PreparedStatement ps=con.prepareStatement("insert into movies values(?, ?, ?)"); ps.setString(1, title); ps.setString(2, description); ps.setString(3, released_string); int i=ps.executeUpdate(); } catch(Exception se) { se.printStackTrace(); } } } </code></pre> <p>I am newbie in Java, but what am I missing in this example? Changing the method how the form is sent out didn't work out...</p> <p>Thank you in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload