tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uma Maheswar" <h...@globalleafs.com>
Subject Writing beans
Date Wed, 06 Mar 2002 16:15:45 GMT
Hi,
I need help writing a bean inside my JSP programme. I am also attaching my JSP programme,
please check it and do the need ful changes.


<%@ page import="java.sql.*,java.io.*,javax.servlet.*,javax.servlet.http.*,java.util.*"
%>

<html>
<%!
 String iam,seeking,lookingfor,firstname,lastname,address,city,state,country,email;
 String userid,password1,password2,newsletter,offers,totdate;
 int slno,pincode,phone,count=0,month,date,year;
 Connection con = null;
 Statement st,st1;
 ResultSet rs,rs1;
 Calendar cal;
 java.sql.Date sqlDate;
%>
<%
 try
 {

  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  con = DriverManager.getConnection("jdbc:odbc:umasql","sa","bhavanid");
  st = con.createStatement();
  st1 = con.createStatement();

  firstname = request.getParameter("firstname");
  lastname = request.getParameter("lastname");
  address = request.getParameter("address");
  city = request.getParameter("city");
  state = request.getParameter("state");
  country = request.getParameter("country");
  pincode = Integer.parseInt(request.getParameter("zipcode"));
  email = request.getParameter("email");
  phone = Integer.parseInt(request.getParameter("phone"));

  userid = request.getParameter("nickname");
  password1 = request.getParameter("password1");
  password2 = request.getParameter("password2");
  newsletter = request.getParameter("newsletter");
  offers = request.getParameter("offers");

  rs1 = st1.executeQuery("select * from Dating_Register where nickname='"+userid+"' ");
  out.println("<html><head>");
  out.println("</head>"); 

  if(rs1.next())
  {
   out.println("<h4><font color=red>Sorry the user already exists</font></h4>");
   //printContent();
  }
  else if(!(password1.equals(password2)))
  {
   out.println("<h4><font color=red>Please type both the passwords same</font></h4>");
   //printContent();
  }
  else
  {

   String inserting = "insert into Dating_Register values("+count+",'"+iam+"','"+seeking+"','"+lookingfor+"','"+firstname+"','"+lastname+"','"+address+"','"+city+"','"+state+"','"+country+"',"+pincode+",'"+email+"',"+phone+","+sqlDate+",'"+userid+"','"+password1+"','"+password2+"','"+newsletter+"','"+offers+"')";

   int x = st1.executeUpdate(inserting);

   out.println("<center><b>Registered Successfully</b></center>");
   out.println("<form name=login action='/servlet/Login' method='post'>");
   out.println("<table><tr><td>Nickname:</td><td><input type=text
name=userid size=15></td></tr>");
   out.println("<tr><td>Password:</td><td><input type=password
name=pass size=15></td></tr></table>");
   out.println("<input type=submit value='Login' name=login>&nbsp;<input type=reset
value='Reset' name=reset>");
   out.println("</form>");

  }

 }
 catch(Exception e)
 {
  e.printStackTrace();
 }
%>

<%!


 public void printContent()
 {

  This is my bean code, It is a big code, so I am not pasting it here.
   It is actually recalling the HTML page when the user already exists or the password is
not valid. Do, I have to say "out.println" statement for each and every HTML line?
 }






%>
</body>
</html>


Thank you,
Regards
Uma

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message