Wednesday, March 6, 2013

Registration page demo in JSP


Registration page demo  in JSP....

Steps to follow for connecting to DBMS

Load the driver class into the runtime environment by using the forName() method of java.lang class. This method accepts a string parameter to contain the class name. This method throws a java.lang class not found Exampleception. The class is a predefined class and forName is the static method of the class, which is used to load the driver into memory for connectivity.

Example:- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")

Create a reference of java.sql.connection by using the getConnection() method of java.sql.DriverManager class. This method accepts three parameters as part of the driver in the JDBC:ODBC bridge. We are required to provide a DSN(Data source name) in this position. DSN can be created in control panel

Example: Connection con=DriverManager.getConnection("jdbc:odbc:dsnname","system","password");

The getConnection() method throws a java.sql.sql Exampleception.

Create an instance of java.sql statement by using the create() method of connection. The statement is being used to execute various sql commands.

Example:- Statement stmt=con.createStatement();

Use an appropriate method of statements to Exampleecute sql command for select command use the ExampleecuteQuery() method and for insert, update and delete use ExampleecuteUpdate() method.
What is DSN?

This is a name provided to the DBMS driver present in ODBC. This recognizes the database to be used by a specific DBMS.

Creation of dsn(database source name) for Oracle

Start-Control panel- Administrative Tools- Data Sources (ODBC)-go to system dsn tab-click add button-select a driver for which you want to set up a data source (for Oracle- Oracle in XE)-select it and click finish-give any name in data source name tExampletbox-then click ok button.

Note:- Here Username=system, Password=pintu and Dsn name=dsn1

In this registration page, we are using CSS, a Java script for validation of the blank form, confirm password and email validation. Here we also use a HTML page where the user can enter there details and after submitting the button action goes to the doRegister.jsp page where data is being saved in the database and the registered user name is shown as output in the success.jsp page.

Table creation

create table employee(name varchar(50),pass varchar(50),cpass varchar(50),email varchar(50),phone int,fax int,city varchar(50),state varchar(50),zip varchar(50))

Account.html page 
<html>
<head>
<title>Untitled Page</title>
<link href="./STYLE.css" rel="stylesheet" type="tExamplet/css" />
<style type="tExamplet/css">
.deepbluetExampletbold { font: Bold 10pt Verdana, Helvetica, sans-serif; color: #006db9;}
.colouredCell { background-color: #eeeeee;}
</style>
<script language="javascript">
function validate(objForm){
if(objForm.t1.value.length==0){
alert("Please enter Name!");
objForm.t1.focus();
return false;
}

if(!(isNaN(document.objForm.t1.value)))
{
alert("Name has character only!");
return false;
}

if(objForm.t2.value.length==0){
alert("Please enter Password!");
objForm.t2.focus();
return false;
}

if(objForm.t3.value.length==0){
alert("Please enter Confirm password!");
objForm.t3.focus();
return false;
}

if(document.getElementById("t2").value!=document.getElementById("t3").value)
{
alert("Confirm Password doesnot match!");
document.getElementById("t3").focus();
return false;
}

if(objForm.t4.value.length==0){
alert("Please enter Email!");
objForm.t4.focus();
return false;
}

if (document.objForm.t4.value != "")
{
var Temp = document.objForm.t4
var AtSym = Temp.value.indExampleOf('@')
var Period = Temp.value.lastIndExampleOf('.')
var Space = Temp.value.indExampleOf(' ')
var Length = Temp.value.length - 1
if ((AtSym < 1) ||
(Period <= AtSym+1) ||
(Period == Length ) ||
(Space != -1))
{
alert("Please enter a valid Email ID!");
document.objForm.t4.focus();
return false;
}
}

if(objForm.t5.value.length==0){
alert("Please enter Phone!");
objForm.t5.focus();
return false;
}

if(objForm.t6.value.length==0){
alert("Please enter Fax!");
objForm.t6.focus();
return false;
}

if(objForm.t7.value.length==0){
alert("Please enter City!");
objForm.t7.focus();
return false;
}

if(!(isNaN(document.objForm.t7.value)))
{
alert("City has character only!");
objForm.t7.focus();
return false;
}

if(objForm.t8.value.length==0){
alert("Please enter State!");
objForm.t8.focus();
return false;
}

if(!(isNaN(document.objForm.t8.value)))
{
alert("State has character only!");
objForm.t8.focus();
return false;
}

if(objForm.t9.value.length==0){
alert("Please enter Zip!");
objForm.t9.focus();
return false;
}

return true;
}
</script>
</head>
<body >
<form name ="objForm" action="./doRegister.jsp" method="post" onSubmit="return validate(this)">
<table>
<tr>
<td class="deepbluetExampletbold"><b>Create a user account</b></td>
</tr>
<tr>
<td class="colouredCell"><b>Name*</b></td>
<td><input name="t1" type="tExamplet " /></td>
</tr>
<tr>
<td class="colouredCell"><b>Password*</b></td>
<td><input name="t2" type="password" /></td>
</tr>
<tr>
<td class="colouredCell"><b>Confirm password*</b></td>
<td><input name="t3" type="password" /></td>
</tr>
<tr>
<td class="colouredCell"><b>Email*</b></td>
<td><input name="t4" type="tExamplet" /></td>
</tr>
<tr>
<td class="colouredCell"><b>Phone*</b></td>
<td><input name="t5" type="tExamplet" /></td>
</tr>
<tr>
<td class="colouredCell"><b>Fax*</b></td>
<td><input name="t6" type="tExamplet" /></td>
</tr>

<tr>
<td class="colouredCell"><b>City*</b></td>
<td><input name="t7" type="tExamplet" /></td>
</tr>
<tr>
<td class="colouredCell"><b>State*</b></td>
<td><input name="t8" type="tExamplet" /></td>
</tr>
<tr>
<td class="colouredCell"><b>Zip*</b></td>
<td><input name="t9" type="tExamplet" /></td>
</tr>
</table>
<input type="submit" value="Register"/>
</form>
</body>
</html>

doRegister.jsp

<%@ page import="java.sql.*" %>
<%
String str1=request.getParameter("t1");
String str2=request.getParameter("t2");
String str3=request.getParameter("t3");
String str4=request.getParameter("t4");
String str5=request.getParameter("t5");
String str6=request.getParameter("t6");
String str7=request.getParameter("t7");
String str8=request.getParameter("t8");
String str9=request.getParameter("t9");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:dsn1","system","pintu");
PreparedStatement pstmt=con.prepareStatement("insert into employee(name,pass,cpass,email,phone,fax,city,state,zip) values(?,?,?,?,?,?,?,?,?)");
pstmt.setString(1,str1);
pstmt.setString(2,str2);
pstmt.setString(3,str3);
pstmt.setString(4,str4);
pstmt.setString(5,str5);
pstmt.setString(6,str6);
pstmt.setString(7,str7);
pstmt.setString(8,str8);
pstmt.setString(9,str9);
pstmt.ExampleecuteUpdate();
con.close();
%>
<jsp:forward page="/success.jsp">
<jsp:param name="reg" value="<%= str1 %>" />
</jsp:forward>

success.jsp

<html>
<body>
<%
String str1=request.getParameter("t1");
%>
<h4><font color='Red'>Welcome:::</font><b><font color='#663300'><%= str1 %></font></b></h4>
</body>
</html>

Running the application

http://localhost:8081/jsp/



Login page Demo in jsp with NetBeans & SQL Server..


Step 1: Open SQL Server –>Create Data Base->Create Table->Insert Value

Step 2: Create Data Base

 create database JavaTest ( Select line and press F5)
use JavaTest ( Select line and press F5)
Create table Login
(
       username varchar(20),
       userpass varchar(20)
)
insert into Login values('niit','password')
select * from Login
username             userpass            
-------------------- --------------------
niit                 password
(1 row(s) affected)


Step 3: Create DSN Name for your database 


Step 4: Open Netbeans

Add Login.jsp Page

<%--
    Document   : Login
    Created on : Mar 21, 2012, 12:15:05 AM
    Author     : dell_pc
--%>
<%@page contentType="text/html" pageEncoding="UTF-8" import="java.sql.*" language="java"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body bgcolor="pink">
<form name="f1" action="" method="post">
    <table align="center">
<tr>
<td>User Name</td><td><input type="text" name="name" ></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password"  name="pass"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="btnsubmit" value="LogIn"></td>
</tr>
    </table>
<%
String user=request.getParameter("name");
String pass=request.getParameter("pass");
     try{
     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
     Connection con=DriverManager.getConnection("jdbc:odbc:javadsn", "sa", "niitbpld95");
     Statement st=con.createStatement();
     ResultSet rs=st.executeQuery("select * from login");
     while(rs.next())
         {
         String username=rs.getString(1);
         String password=rs.getString(2);
         if(user.equals(username) && pass.equals(password))
             {
             %>
             <jsp:forward page="LoginSuccess.jsp" />
         <%}
         else
         out.println("Login Failed,Please try Againe");
         %>
         <%
     }
}catch(Exception e1)
{}
%>
</form>
</body>
</html>
LoginSuccess.jsp

<%--
    Document   : LoginSuccess
    Created on : Mar 21, 2012, 12:20:49 AM
    Author     : dell_pc
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!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=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>U sucessfuly Entered</h1><br>
        <h2>Welcome to My Blog</h2>
    </body>
</html>


Step 5: deploy your project in Tomcat or any other server


Step 6: Run your project
output:







Thursday, November 29, 2012

CE 9402 STRUCTURAL DYNAMICS AND EARTHQUAKE ENGINEERING


CE 9402 STRUCTURAL DYNAMICS AND EARTHQUAKE ENGINEERING L T P C
3 0 0 3
OBJECTIVE:
To provide a basic understanding of dynamic loading. Study the effect of earthquake loading
on the behaviour of structures. Understand the codal provisions to design the structures as
earthquake resistant.
UNIT I SINGLE DEGREE OF FREEDOM SYSTEMS 9
Formulation of equation of motion, Free and forced vibrations, Damping, Types of Damping-
Damped and undamped vibrations, Response to dynamic loading.
UNIT II MODAL ANALYSIS 9
Free and forced vibration of undamped and damped MDOF systems. Equation of motions,
Evaluation of natural frequencies and modes, Eigen Values and Eigen Vectors
UNIT III INTRODUCTION TO EARTHQUAKE ENGINEERING 9
Elements of Engineering Seismology, Characteristics of Earthquake Engineering, Earthquake
History, Indian Seismicity.
UNIT IV BEHAVIOUR OF STRUCTURES AND SOIL 9
Performance of structures under past earthquakes, Lessons learnt from past earthquakes–
soil liquefaction - Soil – Structure- Interaction (SSI) effects.
UNIT V EARTHQUAKE RESISTANT DESIGN 9
Concept of Earthquake Resistant Design, Provisions of Seismic Code IS 1893 (Part I),
Response Spectrum, Design Spectrum, Design of Buildings, Reinforcement Detailing,
Provisions of IS 13920.
TOTAL: 45 PERIODS
TEXT BOOKS:
1. Agarwal and Shrikhande,”Earthquake Resistant Design of Structures”, Prentice Hall of
India, 2007
2. Clough R.W, and Penzien J , Dynamics of Structures, Second Edition, Mc Graw – Hill
International Edition, 1993
REFERENCES:
1. Mario Paz, Structural Dynamics – Theory and Computations, Third Edition, CBS
publishers, 1990.
40
2. Jaikrishna, A.R. Chandrasekaran and Brijesh Chandra, “Elements of Earthquake
Engineering”, South Asia Publishers, New Delhi.
3. Minoru Wakabayashi, “Design of Earthquake Resistant Buildings”, Mc Graw – Hill Book
Company, New York, 1986
4. Humar J L “Dynamics of Structures”, Prentice Hall, 1990.
5. Anil K Chopra, “Dynamics of structures – Theory and applications to Earthquake
Engineering”, Prentice Hall Inc., 2001.
6. C V R Moorthy, “Earthquake Tips”, NICEE, IIT Kanpur, 2004