<%@ page import="java.sql.*"%>




<%String fname=request.getParameter("name");
   String lname=request.getParameter("last");
   String id= request.getParameter("id");
   String pass=request.getParameter("password");
   String pass1=request.getParameter("passcon");
   String month=request.getParameter("Months");
   String date=request.getParameter("date");
   String year=request.getParameter("year");
   String gender=request.getParameter("gender");
   String country=request.getParameter("country");
   %>
<%=try
 {
 Connection c=null;
   Statement st= null;
  DriverManager dm=null;
  String pass="";
  String user="";
  PreparedStatement pt=null;

 String url="Jdbc:Odbc:jaggi";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
c=dm.getConnection(user,pass,url);



  if(pass.equals(pass1))
   {
  




   
   pt=c.prepareStatement(insert into Registration values(?,?,?,?,?,?,?,?,?));
    pt.setString(1,fname);
    pt.setString(2,lname);
    pt.setString(3,id);
    pt.setString(4,pass);
    pt.setString(5,month);
    pt.setString(6,date);
    pt.setString(7,year);
    pt.setString(8,gender);
    pt.setString(9,country);
   
   pt.executeUpdate();
  application.setAttribute("name",fname);
    application.setAttribute("ID",id);
    RequestDispatcher r=application.getRequestDispatcher("/Welcome.jsp");
 if(pt.equals(true))
  {
     r.forward(request,response);
   }
   else
   {
      //JOptionPane.showMessageDialog(null,"Your Registration Failed plz try again");
   }
}
 else
   {
      //JOptionPane.showMessageDialog(null, "Please enter Correct Password");
   }
c.close(); 
  }

 catch(Exception e)
 {
    //JOptionPane.showMessageDialog(null,e);
  }%>

Above code is for JSP its not running please tell me the error and how to run this file.
And the html file for above code is given below

<html>

<body bgcolor="gray" text="white">
	<form action="http://localhost:7001/Jaggi/Registration.jsp" >
<h1 align="center">Registration Form</h1>

<style type="text/html">
	h1 {color:blue}
</style>

<fieldset>



First name
	&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp  &nbsp &nbsp &nbsp &nbsp &nbsp  :<input type="text" name="first">

 . &nbsp &nbsp Last name 
	   &nbsp &nbsp &nbsp &nbsp  :<input type="text" name="last">

<br><br>

Choose your Yahoo ID
           &nbsp :<input type="text" name="id">	

.&nbsp <input type="button" name="check" value="Check availability" >

<br><br>
 Choose Password 
	   &nbsp &nbsp &nbsp &nbsp &nbsp  :<input type="password" name="password">
<br><br>
Confirm your Password 
	       &nbsp  :<input type="password" name="passcon"><br><br>


Date of Birth
&nbsp &nbsp &nbsp &nbsp  &nbsp &nbsp &nbsp &nbsp &nbsp  :<select size="1" name="Months"><option value= Month selected>Month</option><option 
  value=January >january</option> <option value="feburay">feburay</option> 
  <option value="March">march</option> <option value="April">April</option> <option 
  value=may>may</option> <option value="june">june</option> <option 
  value=" july">july</option> <option value=" Augst">Augst</option><option value= "September">September</option>

 <option value= "October">October</option> <option value= "November">November</option>
 <option value="December">December</option> 


 </select>


<input type="text" name="date"value= "dd" size=3>
<input type="text" name="year" value =" yyyy"size=5><br><br>

Gender 

&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp  &nbsp &nbsp &nbsp &nbsp &nbsp :<select size="1" name="gender"><option value=select selected>select</option>
<option value="Male">Male</option>
<option value="Female">Female</option></select><br><br>

Country

 &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp  &nbsp &nbsp &nbsp &nbsp &nbsp :
<select size=1 name="country"><option value=Select selected>Select</option>
<option value="India">India</option>
<option value= "United States">United States</option>
<option value= "United Kingdom">United Kingdom</option>
<option value= "Canada">Canada</option>
<option value= "Singapure">SingaPure</option>
<option value= "Malasiya">Malasiya</option>
<option value= "Australia">Australia</option>
<option value= "Suadia Arabia">Suadia Arabia</option>
<option value= "United Arab Emirates">United Arab Emirates</option>
<option value= "South Africa">South Africa</option>
<option value= "Phillipens">Phillipens</option>
<option value= "Pakistan">Pakistan</option>
<option value= "China">China</option>
<option value= "Japan">Japan</option>
<option value= "Italy">Italy</option></select><br><br>

Verify Your Registration
  :
<input type="text" name="verify"style=" font-size: 20px;" size=15 >
<LABEL FOR="verifycode">
<--Enter the code in the image here 

</LABEL>
      &nbsp &nbsp &nbsp 
<input type="text"  style="background-image:url([url]http://register.rediff.com/register/include/display_image.php);[/url] background-repeat: no-repeat; background-position: center center; font-size: 19px;"size=0 />

<br><br>
<input type="submit" name="register" value="Register Me"align="center">
<input type="button" name="cancel" value="Cancle" align="center">





</fieldset> 



</form>

</body>
</html>
  1. Use of code tag [code] YOUR CODE HERE [/code] while posting any code, even one line, is mandatory
  2. @"Above code is for JSP its not running please tell me the error and how to run this file." - it is up to you to tell us what sort of errors you getting, or you think we will flood ours servers with all error filed codes posted from everyone?
  3. Database connectivity from JSP is RUDE thing to do

PS: Can you explain what you are planning to do with JOptionPane.showMessageDialog() in JSP?

there is also a jsp board on this site :X

  1. Use of code tag [code] YOUR CODE HERE [/code] while posting any code, even one line, is mandatory
  2. @"Above code is for JSP its not running please tell me the error and how to run this file." - it is up to you to tell us what sort of errors you getting, or you think we will flood ours servers with all error filed codes posted from everyone?
  3. Database connectivity from JSP is RUDE thing to do

PS: Can you explain what you are planning to do with JOptionPane.showMessageDialog() in JSP?

Well With JOptionPane.showMessageDialog() is used for the client to show some message like that if enter the wrong password or left anu entry blank.
And you says that Jdbc with jsp is a rude thing why, if so then please suggest me then how i do the jdbc conectivity to my code.
And thanks for your reply

Maybe when you read for example this you will get why

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.