Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2012
    Posts
    1
    Rep Power
    0

    Default Need Help with Register Form(jsp servlet postgresql)

    Hi!
    I am working on creating the register system, I am a new on Java programming, can you guys please check my code, because I don't know why it doesn't work(i run my project from netbeans on glassfish server). After I have fill up the form and press submit I have a page with HTTP Status 404 - and descriptionThe requested resource () is not available.


    Form
    --------------
    <form action="/RegisterServlet" method="post" id="">
    <ol>
    <li>
    <label for="username">Username</label>
    <input type="text" name="username" id="username" />
    </li>
    <li>
    <label for="email">Email Address</label>
    <input type="text" name="email" id="email" />
    </li>
    <li>
    <label for="website">Password</label>
    <input type="password" name="password" id="password" />
    </li>

    <li>
    <input type="submit" name="register" id="register" value="Register"/>
    <div class="clr"></div>
    </li>
    </ol>
    </form>


    servlet
    ------------
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;

    public class RegisterServlet extends HttpServlet
    {
    public void doGet(HttpServletRequest request,HttpServletResponse response)
    throws ServletException,IOException
    {
    response.setContentType("text/html");
    PrintWriter out=response.getWriter();
    String name=request.getParameter("username");
    String email=request.getParameter("email");
    String password=request.getParameter("password");
    try
    {
    Class.forName("org.postgresql.Driver");
    Connection con=DriverManager.getConnection("jdbc:postgresql://localhost:8088/users","postgres","199326");
    PreparedStatement stmt=con.prepareStatement("insert into users values(?,?,?)");
    stmt.setString(1, name);
    stmt.setString(2, email);
    stmt.setString(3, password);
    int i=stmt.executeUpdate();
    out.println("<b>You are successfully Registered</b>");
    con.close();
    }
    catch(Exception e)
    {
    out.println("<b>Registration failed</b>");
    out.println("<b>Error:</b>" +e);
    }
    }
    }

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    760
    Rep Power
    8

    Default Re: Need Help with Register Form(jsp servlet postgresql)

    Have you register your RegisterServlet servlet in the web.xml file? and have you define a correct servlet-mapping too?

Similar Threads

  1. simple form & Servlet help
    By bhavinragha in forum Java Servlet
    Replies: 4
    Last Post: 01-27-2012, 07:42 PM
  2. Replies: 0
    Last Post: 10-31-2009, 09:24 AM
  3. how can i link html+servlet+xml to form servlet
    By balachandarr in forum Java Servlet
    Replies: 0
    Last Post: 04-15-2009, 04:06 PM
  4. Servlet with a Form/Dropdown
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-16-2008, 10:24 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •