0

I work on my graduation project on 2 different computers, the problem is every time i copy from here to there i get endless errors and problems specifically with on submit servlets for example i have a registration form that takes registered user info through a servlet to another which connects it to another database, when i tried on one of the computers it worked fine but now as i took it home i get the The requested resource () is not available. error.

Here is the registration JSP form method and submit

<form name="myForm" action="RegisterUSER" onsubmit="return validateForm()"            method="post">

Here i have all the registration fields and drop boxes and at the ned i have this

   <input type="submit" value="Register" name="Register" />
   </br>
   </form>

And here is the servlet that it should submit to(the one netbeans cant find).

import java.io.*;
import java.net.*;

import javax.servlet.*;
import javax.servlet.http.*;

public class RegisterUSER extends HttpServlet {


    protected static void processRequest(HttpServletRequest request, HttpServletResponse   response)
   throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();

        String First_Name=request.getParameter("FirstName");
        String Middle_Name=request.getParameter("MiddleName");
        String Last_Name=request.getParameter("LastName");
        String Username=request.getParameter("Username");
        String Email_Address=request.getParameter("EmailAddress");
        String Password=request.getParameter("Password");
        String Birth_date=request.getParameter("Birthdate");
       String ID=request.getParameter("ID");

    Connecttodatabase con=new Connecttodatabase();
    int x=0;
    try{
 x =con.insertusersToDatabase(First_Name, Middle_Name, Last_Name, Username, Email_Address, Password, Birth_date, ID);
    }
     catch(Exception e){
            System.err.println("Got an exception!");
            System.err.println(e.getMessage());
         }
out.println("<html>");
        out.println("<head>");
        out.println("<title>Servlet Registration</title>");
        out.println("</head>");
        out.println("<body>");
        request.getContextPath ();
       out.println("Registration Complete " +x);
       out.println(Username);

        out.println("</body>");
        out.println("</html>");

        out.close();
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        try{
        processRequest(request, response);
        } catch(Exception e){
            System.err.println("Got an exception!");
            System.err.println(e.getMessage());
         }
    }

    /** Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        try{
        processRequest(request, response);
        } catch(Exception e){
            System.err.println("Got an exception!");
            System.err.println(e.getMessage());
         }
    }

    /** Returns a short description of the servlet.
     */
    public String getServletInfo() {
        return "Short description";
    }
    // </editor-fold>
}

1 Answers1

0

The container is unable to map the URL to your servlet. The problem is likely in your web.xml.

jgitter
  • 3,396
  • 1
  • 19
  • 26
  • Can you be more detailed? i am a business adminstration student and it's my first time doing something using netbeans so i am not that experienced. – user3338096 Feb 21 '14 at 16:55
  • Yes, I can help, but I'll need to see your web.xml before I can do anything. – jgitter Feb 21 '14 at 17:02
  • Also, I feel compelled to give you a piece of advice. Use version control and checkout the code in both places. Don't try to copy/paste folders around or things will get missed or worse, you will inadvertently overwrite newer code with older code and lose progress. – jgitter Feb 21 '14 at 17:17
  • After doing some research the web.xml should be located in the projectfolder\web\WEB-INF\web.xml? if so there is no web.xml located in that folder :\. – user3338096 Feb 21 '14 at 17:32
  • Then how are you deploying? Are you building a .war? Or are you just dropping jars into tomcat or something? – jgitter Feb 21 '14 at 17:41
  • Not sure what you mean but i created a web application project on netbeans started creating my servlets and jsps using an apache tomcat server and ijust copy my project folder to another computer and open it but usually i have to copy the servlets and jsps over to a new project for it to work without giving me so much errors, this time though that's not working and creating a new servlet with a different name still giving me the same error that it's not available. – user3338096 Feb 21 '14 at 17:57
  • It sounds to me like you are using an embedded tomcat server in netbeans to do automatic deployments for development/testing. I'm sorry but without more detail about how you're currently configured I can't help you much. I don't use netbeans much. – jgitter Feb 21 '14 at 18:40
  • Well if i knew what kind of details you need i would give it to you but i really don't. – user3338096 Feb 21 '14 at 22:22
  • I don't know how to thank you enough for bringing the use of an xml to deploy, as i said it as my first time using Netbeans and after doing enough research on the web i managed to create a new project and re created all servlets but this time i created an XML and ticked the option to add to web.xml every time i created a servlet. So far everything is working great, thanks again for your help :). – user3338096 Feb 22 '14 at 09:09
  • I'm glad I could help in some way. Good luck with your project! – jgitter Feb 24 '14 at 14:19