Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 3rd, 2005, 01:06 AM
Registered User
 
Join Date: Mar 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default JSP validation

Hello,
I have just started learning JSP....... So i hv very basic doubts........

This is simple JSP form ........
<html>
<head>
<title>new user</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">


<h1>Please enter your details</h1>


<form action="valid_1st_user.jsp" method="post">
    <table cellspacing="5" cellpadding="5" border="1">
        <tr>
            <td align="right">Name:</td>
            <td><input type="text" name="NewName"></td>
        </tr>
        <tr>
            <td align="right">Email Address:</td>
            <td><input type="text" name="EmailAddress"></td>
        </tr>
        <tr>
            <td align="right">Nationality:</td>
            <td><input type="text" name="Nationality"></td>
        </tr>
        <tr>
            <td align="right">User Name:</td>
            <td><input type="text" name="UserName"></td>
        </tr>
        <tr>
            <td align="right">Password:</td>
            <td><input type="password" name="Password"></td>
        </tr>

    </table>
    <input type="submit" value="Submit">

</form>

</body>
</html>


After i enter all the details in the form, it should be validated & the code is,





<html>
<head>
<title>Validate New User</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page import="java.sql.*" %>

<%
        Connection con = null;

        String names = request.getParameter("NewName");
        String eaddress = request.getParameter("EmailAddress");
        String nation = request.getParameter("Nationality");
        String userid = request.getParameter("UserName");
        String pw = request.getParameter("Password");



        try {

     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
     Connection Con=DriverManager.getConnection("jdbc:odbc:conect" );
     Statement st=Con.createStatement();
     ResultSet rst = stat.executeQuery(queryText);

       String queryText = ("INSERT INTO studentinfo "+('"+Names+"', '"+EAddress+",'
'"+Nation+"', '"+userid+"','"+password+"')

"values("+names+","+eaddress+","+nation+","+userid +","+pw+")");




     rst.close();
     st.close();
     Con.close();
  }
   catch(Exception e)
    {}





      // response.sendRedirect("success.htm");
%>

But i get error in this code.. Can you please hepl me find the error & i should be abble 2 update my database as well.

Aparna.









Similar Threads
Thread Thread Starter Forum Replies Last Post
Standalone validation + web form validation morbo Struts 0 August 19th, 2008 04:02 AM
Validation using Validation Framework kalyangvd Struts 1 January 2nd, 2008 06:53 AM
About validation... timatlee Access VBA 2 June 21st, 2007 03:44 AM
Please Help. mr_newreq.jsp:78: jsp:useBean can't f batken JSP Basics 0 February 22nd, 2006 09:56 PM
Validation koneruvijay ADO.NET 1 January 6th, 2004 09:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.