java - Servlet error HTTP Status 405 - HTTP method GET is not supported by this URL -


i've written following servlet (search1.java):

package ergasia;  import java.sql.*; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.util.arraylist;  public class search1 extends httpservlet {           @override    public void dopost(httpservletrequest request, httpservletresponse response)       throws servletexception, ioexception     {     response.setcontenttype("text/html");         connection connection= null;         string url = "jdbc:mysql://localhost:3306/";     string dbname = "ergasia";         string user = "root";     string password = "password";      preparedstatement selectproteins = null;     resultset resultset = null;       arraylist al = null;          try {                         connection = drivermanager.getconnection(url + dbname, user, password);             string keyword = request.getparameter("keyword");                         selectproteins = connection.preparestatement("select * protein proteinname ?");             selectproteins.setstring(1, "%" + keyword + "%");             resultset = selectproteins.executequery();                          arraylist keyword_list = new arraylist();                               while (resultset.next()) {                     al = new arraylist();                     al.add(resultset.getstring(1));                     al.add(resultset.getstring(2));                     al.add(resultset.getstring(3));                     al.add(resultset.getstring(4));                     al.add(resultset.getstring(5));                     al.add(resultset.getstring(6));                     al.add(resultset.getstring(7));                                     keyword_list.add(al);                 }              request.setattribute("results", keyword_list);                     requestdispatcher view = request.getrequestdispatcher("/search_proteins.jsp");             view.forward(request, response);          } catch (sqlexception e) {             e.printstacktrace();         }     }     @override     public string getservletinfo() {         return "info";     } }   

that access jsp page following command:

<form method="post" action="/ergasia/search1">  

but when try run tomcat gives me following error: http status 405 - http method not supported url type:status report message:http method not supported url description:the specified http method not allowed requested resource.

here's web.xml file too:

<?xml version="1.0" encoding="utf-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">             <servlet>         <servlet-name>search_proteins</servlet-name>         <servlet-class>ergasia.search1</servlet-class>     </servlet>     <servlet-mapping>         <servlet-name>search_proteins</servlet-name>         <url-pattern>/search_proteins</url-pattern>     </servlet-mapping>     <welcome-file-list>         <welcome-file>index.jsp</welcome-file>     </welcome-file-list> </web-app> 

could please me find i've done wrong?

unfortunately can't post images yet, here configuration, maybe it'll help:1

you servlet doesn't have url-pattern /ergasia/search1, try instead:

<form method="post" action="search_proteins">  

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -