title: HTTP Status 405 - HTTP method GET is not supported by this URL
body: <p>The code below is from a book,so it'll not be incorrect.But I don't know how to solve this below error.When delete the method doGet(),the same error!</p>
  
  <p><strong>"HTTP Status 405 - HTTP method GET is not supported by this URL"</strong></p>
  
  <pre><code>import java.io.BufferedInputStream;
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.IOException;
  import javax.servlet.ServletException;
  import javax.servlet.ServletOutputStream;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  public class PDFServlet extends HttpServlet{
  private static final long serialVersionUID = 1L;
  @Override 
  protected void doGet(HttpServletRequest request,HttpServletResponse response) 
  throws IOException,ServletException{
      this.doPost(request,response);
  }
  @Override 
  protected void doPost(HttpServletRequest request,HttpServletResponse response) 
                                     throws IOException,ServletException{
      response.setContentType("application/pdf");
      ServletOutputStream out=response.getOutputStream();
      File pdf=null;
      BufferedInputStream buf=null;
      try{
          pdf=new File("C:\\Users\\lk\\Desktop\\Desktop\\ example.pdf");
          response.setContentLength((int)pdf.length());
          FileInputStream input=new FileInputStream(pdf);
          buf=new BufferedInputStream(input);
          int readBytes=0;
          while((readBytes=buf.read())!=-1)    out.write(readBytes);
      }catch(IOException e){
          System.out.println("file not found!");
      }finally{
          if(out!=null) out.close();
          if(buf!=null) buf.close();
      }
  }
  }
  </code></pre>
  
  <p>web.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  -&lt;web-app xsi:.........." version="2.5"&gt; 
  -&lt;servlet&gt; 
  &lt;description&gt;This is the description of my Java EE component&lt;/description&gt; 
  &lt;display-name&gt;This is the display name of my Java EE component&lt;/display-name&gt; 
  &lt;servlet-name&gt;PDFServlet&lt;/servlet-name&gt; 
  &lt;servlet-class&gt;PDFServlet&lt;/servlet-class&gt; 
  &lt;/servlet&gt; 
  -&lt;servlet-mapping&gt; 
  &lt;servlet-name&gt;PDFServlet&lt;/servlet-name&gt; 
  &lt;url-pattern&gt;/PDFServlet&lt;/url-pattern&gt; 
  &lt;/servlet-mapping&gt; 
  -&lt;welcome-file-list&gt; 
  &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt; 
  &lt;/welcome-file-list&gt; 
  -&lt;login-config&gt; 
  &lt;auth-method&gt;BASIC&lt;/auth-method&gt; 
  &lt;/login-config&gt; 
  &lt;/web-app&gt;
  </code></pre>