0

I keep getting this error when I am using Netbeans and the internet.

"HTTP Status 405 - HTTP method POST is not supported by this URL"

I don't know just what is going on here, and I will be happy if someone here could help me out. Here is what I got down. It goes like this.

package servlets;

import business.*;
import business.User;
import data.*;
import data.UserIO;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import static javax.ws.rs.client.Entity.html;

/**
 * FFilename: AddDisplayInput.java Date: August September 23, 2014 Author Russell Lindsey
 */
public class AddDisplayInput extends HttpServlet {

/**
 * Processes requests for both HTTP <code>POST</code
 * methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOExceptin if an I/O errr occurs 
 */
protected void processRequest(HttpServletRequest request,
        HttpServletResponse response)
        throws ServletException, IOException {

    // the next 7 lines are the same as in the display_email_entry.jsp file
    String firstName = request.getParameter("firstName");
    String lastName = request.getParameter("lastName");
    String emailAddress = request.getParameter("emailAddress");

    User user = new User(firstName, lastName, emailAddress);

    ServletContext sc = this.getServletContext();
    String path =sc.getRealPath("/Web-INF/EmailList.txt");
    UserIO.add(user, path);
    response.setContentType("text/html;charset=UTF-8");
    try (PrintWriter out = response.getWriter()) {
        /* TODO output your page here. You may use the following sample code. */
        out.println("<!DOCTYPE html>\n");
        out.println("<html>\n");
        out.println("<head>\n");
        out.println("<title>Servlet AddDisplayInput</title>\n");            
        out.println("</head>");
        out.println(" <body\n" +
"    <h1>Thanks for Joining Russell Lindsey's email list</h1>\n" +
"    <p>\n" +
"        Here is the information you entered</p>\n" +
"    </p>\n" +           
"    <p>\n" +
"        First Name: " + user.getFirstName() +" \n" +
"    </p>\n" +
"    <p>\n" +                   
"        Last Name: " + user.getLastName() +" \n" +   
"    </p>\n" +
"    <p>\n" +                   
"        Email Address: " + user.getEmailAddress() + " \n" +
"    </p>\n" +
"\n" +
"    </p>\n" +             
"        Click this button to return to the email entry page:\n" + 
"    </p>\n" +            
"    <form action=\"index.html\" method=\"post\">\n" +
"        <input type=\"submit\" value=\"Return to input\"/>\n" +
"    </form>\n" +
"   \n" +
"</body>");
       out.println("</html>");
    }
}
}<b>

I do not know what I could have possibly wrote down wrong here. Can anyone help me out, here, give some pointers on what to do?

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
  • 1
    possible duplicate of [HTTP status 405 - HTTP method POST is not supported by this URL](http://stackoverflow.com/questions/11222695/http-status-405-http-method-post-is-not-supported-by-this-url) – Nir Alfasi Sep 07 '14 at 01:25
  • 1
    Side note: make sure to add language tag to your future posts. Please also review "related" questions as "405 - post not supported" looks relatively common problem and may already have an answer - if you find existing answer explaining the issue feel free to recommend closing your post as duplicate. – Alexei Levenkov Sep 07 '14 at 01:26
  • How are you making your request? Are you sending a POST? Why do you think it should work? – Sotirios Delimanolis Sep 07 '14 at 01:39
  • You have any better ideas, Sotirios? – Russell Lindsey Sep 07 '14 at 02:03

0 Answers0