Am trying to link from a JSP to a servlet . On clicking the button with the name="conf" I need to redirect to a servlet "/Initial" . The problem is when I use type="button" nothing happens, while when I use type="submit" the page gets directed to servlet "/Initial" and does the action there. Am not able to identify the problem.
Here is my code:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page import="reg.serv.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
</head>
<body>
    <form method="post">
        <center>
            <table border="1" width="30%" cellpadding="3">
                <thead>
                    <tr>
                        <th colspan="2">Register Here</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>Username</td>
                        <td><input type="text" class="" id="username" name="username1" value="" /></td>
                    </tr>
                    <tr>
                        <td>Password</td>
                        <td><input type="password" name="password1" id="password" value="" /></td>
                    </tr>
                    <tr>
                        <td>Confirm Password</td>
                        <td><input type="password" name="confirmpassword1" id="confirmpassword" value="" /></td>
                    </tr>
                    <tr>
                        <td>Mobile Number</td>
                        <td><input type="text" class="" id="mob" name="mob1" value="" /></td>
                    </tr>
                    <tr>
                        <td>Email ID</td>
                        <td><input type="text" class="" id="email" name="email1" value=" " /></td>
                    </tr>
                    <tr>
                        <td>Address</td>
                        <td><textarea id="address" name="address1"></textarea></td>
                    </tr>
                    <tr>
                        <td colspan="2">Already registered <a href="Index.jsp">Login Here</a></td>
                    </tr>
                </tbody>
                <tr>
                    <td><input type="button" value="confirm" name="conf" /></td>
                    <td><input type="reset" value="Reset" /></td>
                    <td><input type="button" value="Cancel" name="Cr" onclick="openPage('Initial.jsp')" /></td>
                </tr>
        </table>
    </form>
    <script type="text/javascript">
        function openPage(pageURL) {
            window.location = pageURL;
        }
    </script>
    <%
        String x = request.getParameter("conf");
        if (x != null && x.equals("confirm")) {
            //response.sendRedirect("/Initial");
            RequestDispatcher dispatcher = request.getRequestDispatcher("/Initial");
            dispatcher.forward(request, response);
        }
    %>
</body>
</html>
Please help me . Any help would be greatly appreciated. Thanking You.
 
     
     
     
     
     
     
     
    
: [The HTML ` – informatik01 Jan 08 '15 at 17:53