WT All Weeks.

Download as pdf or txt
Download as pdf or txt
You are on page 1of 46

For latest technology news visit us at http://www.devilsduke.

com

1. Design the following static web pages required for an online book store web site Home page The static home page must contain 3 frames. - Top Frame: It contains logo home page, login, registration, catalogue, cart - Left Frame: It contains four navigation frames which will display the catalogue of respective links. - Right Frame: The page to the links in the left frame must be loaded here. Registration and user Login User Profile Page Books catalog Shopping Cart Payment By credit card Order Conformation

Procedure: < Main.html > <html> <head> <frameset rows="10%,15%,*"> <frame src="head.html"> <frame src="table1.html" scrolling="no"> <frameset cols="10%,90%"> <frame src="branch.html"> <frame src="right.html" name="desc"> </frameset> </frameset> </head> </html> < Head.html > <html> <body> <h1 align="center"><b><font color="blue">Web Site Name</font></b></h2> </body> </html>

< Table1.html > <html> <body> <table align="center" width="101%" height="100%">

For latest technology news visit us at http://www.devilsduke.com

<tr> <th bgcolor="pink">LOGO <br>home <th bgcolor="green"><a href="login.html" target="desc">login</a> <th bgcolor="yellow"><a href="reg.html" target="desc">Registration </a> <th bgcolor="manganta"><a href="catlog.html" target="desc">catlog </a> <th bgcolor="purple"><a href="cart.html" target="desc">Cart </a> </tr> </table> </body> </html>

< Branch.html > <html> <head> </head> <body> <h3 align="center"><a href="catlog.html#cse" target="desc"> CSE </a></h3> <h3 align="center"><a href="catlog.html#ece" target="desc">ECE </a></h3> <h3 align="center"><a href="catlog.html#eee" target="desc">EEE </a></h3> <h3 align="center"><a href="catlog.html#civil" target="desc">CIVIL</a></h3> </body> </html>

< Right.html > <html> <head> </head> <body bgcolor="pink"> <h1 align="center"> WELCOME TO ONLINE BOOK SHOP </h1> </body> </html>

For latest technology news visit us at http://www.devilsduke.com

Output:

For latest technology news visit us at http://www.devilsduke.com

< Login.html > <html> <head> <title> login page </title> </head> <body bgcolor="cyan"> <center> <right> <table > <tr> <td><h4>user name</td> <td><input type="text" ></td> <td></td> </tr> <tr> <td><h4>password</td> <td><input type="password"></td> <td></td> </tr> <tr> <td> <form method="post" action="catalog.html" > <input type="submit" value="submit" > </form> </td> <td> <form method="post" action="userpro.html" > <input type="submit" value="register" > &nbsp;&nbsp; <input type="reset" value="reset"></form></td> </tr> </table> </body> </html>

For latest technology news visit us at http://www.devilsduke.com

Output:

For latest technology news visit us at http://www.devilsduke.com

< Catalog.html > <html> <head> <title> books catalog </title> </head> <body bgcolor="cyan"> <form method="post" action="shopping.html"> <left> <table> <tr> <td><b><h3>frontend books</td> <td></td></tr> <tr> <td></td> <td><h4>C&Ds</td> </tr> <tr> <td></td> <td><h4>Ads</td> </tr> <tr> <td></td> <td><h4>JAVA </td></tr> <tr> <td><b><h3>backend books</td> <td></td> </tr> <tr> <td></td> <td><h4>Oracle</td> </tr> <tr> <td></td> <td><h4>Ms SQL Server </td></tr> <tr>2 <td></td> <td><h4>MySql </td> </tr>

For latest technology news visit us at http://www.devilsduke.com

</table> </h4> <center> <b>for buy one of these books <br> </b><input type="submit" value="click here"> </center> </form> </body> </html>

For latest technology news visit us at http://www.devilsduke.com

Output:

For latest technology news visit us at http://www.devilsduke.com

Design the following static web pages required for an online book store web site

Cart Page The cart page contains the details about the books which are added to the cart Registration Create a Registration Form with the following fields 1. Name (text field) 2. Password (password field) 3. Email id (text field) 4. Phone Number (text field) 5. Sex (radio button) 6. Date of birth(3 select boxes) 7. Language known(check boxes) 8. Address(text area)

< Cart.html > <html> <body> <table> <tr> <th> Bookname</th> <th>Price</th> <th>quantity</th> <th>amount</th> </tr> <tr> <td>JAVA 2</td> <td>$35.5</td> <td>2</td> <td>$70</td> </tr> <tr> <td>XML bible</td> <td>$40.5</td> <td>1</td> <td>40.5</td> </tr> <p align='right'><b>total amount:</b> $103.5</p> </table> </body> </html>

For latest technology news visit us at http://www.devilsduke.com

Output:

For latest technology news visit us at http://www.devilsduke.com

Registration Page: < Reg.html > <html> <head> <title> validation </title> </head> <body bgcolor="magenta"> <h1 align="center">REGISTRATION FORM</h1> <form name="vasu"> <table border="0"> <tr> <td>Name:</td> <td><input type="text" name="n" min length="6"></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="pwd"></td> </tr> <tr> <td>E-mail id:</td> <td><input type="text" name="em"></td> </tr> <tr> <td>Phone number:</td> <td><input type="text" name="pn"></td> </tr> <tr> <td>Sex:</td> <td>male<input type="radio">female<input type="radio"></td> </tr> <tr> <td>Date of birth:</td> <td>dd:<select> <option>1 <option>2 <option>3 <option>4 <option>5 <option>6 <option>7

For latest technology news visit us at http://www.devilsduke.com

<option>8 <option>9 <option>10 <option>11 <option>12 <option>13 <option>14 <option>15 <option>16 <option>17 <option>18 <option>19 <option>20 <option>21 <option>22 <option>23 <option>24 <option>25 <option>26 <option>27 <option>28 <option>29 <option>30 <option>31 </select> mm:<select> <option>1 <option>2 <option>3 <option>4 <option>5 <option>6 <option>7 <option>8 <option>9 <option>10 <option>11 <option>12 </select> yy:<select>

<option>1981

For latest technology news visit us at http://www.devilsduke.com

<option>1982 <option>1983 <option>1984 <option>1985 <option>1986 <option>1987 <option>1988 <option>1989 <option>1990 </select></td> </tr> <tr> <td>Languages known:</td> <td>English<input type="checkbox">Telugu<input type="checkbox">hindi<input type="checkbox">Tamil<input type="checkbox"></td> </tr> <tr> <td>Address:</td> <td><textarea rows="5" columns="5"></textarea></td> </tr> <tr> <td><input type="submit" value="submit" onclick="validate()"></td> <td><input type="reset" value="cancel"></td> </tr> </table> </forms> </body> </html>

For latest technology news visit us at http://www.devilsduke.com

Output:

For latest technology news visit us at http://www.devilsduke.com

Write a Java Script to validate the following fields of the registration page 1. Name (Name should contain alphabets). 2. Password (Password should not be less than 6 characters length). 3. E-mail id (should not contain any invalid and must follow the standard pattern name@domain.com). 4. Phone number (phone number should contain 10 digits only). Procedure: < Validation.html > <html> <head> <script language=javascript> function validate() { var name1=document.vasu.n.value; var pwd1=document.vasu.pwd.value; var eid1=document.vasu.em.value; var pn1=document.vasu.pn.value; var name2=new RegExp("[a-z]"); var pwd2=new RegExp("[a-z]|[0-9]"); var eid2=new RegExp("[a-z]+[@]+[a-z]"); var pn2=new RegExp("[0-9]"); if(name1=="" | pwd1=="" | eid1=="" | pn1=="") { if(name1=="") { alert(".....blank spaces not allowed in name....."); } if(pwd1=="") { alert(".....blank spaces not allowed in Password....."); } if(eid1=="")

{ alert(".....blank spaces not allowed in E-mail id....."); } if(pn1=="") {

For latest technology news visit us at http://www.devilsduke.com

alert(".....blank spaces not allowed in phone number....."); } } else if(name1.match(name2)) { if(pwd1.match(pwd2)) { if(eid1.match(eid2)) { if(pn1.match(pn2)) { alert(".....you entered valid information....."); } else { alert(".....invalid phone number....."); } } else { alert(".....invalid E-mail id....."); if(pn1.match(pn2)) { } else { alert(".....invalid phone number....."); } } } else { alert(".....invalid password....."); if(eid1.match(eid2)) { } else { alert(".....invalid E-mail id....."); } if(pn1.match(pn2)) {

For latest technology news visit us at http://www.devilsduke.com

} else { alert(".....invalid phone number....."); } } } else { alert(".....invalid name....."); if(pwd1.match(pwd2)) { } else { alert(".....invalid password....."); } if(eid1.match(eid2)) { } else { alert(".....invalid E-mail id....."); } if(pn1.match(pn2)) { } Else

{ alert(".....invalid phone number....."); } } } </script> <title> validation </title> </head> <body bgcolor="magenta"> <h1 align="center">REGISTRATION FORM</h1> <form name="vasu"> <table border="0">

For latest technology news visit us at http://www.devilsduke.com

<tr> <td>Name:</td> <td><input type="text" name="n" min length="6"></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="pwd"></td> </tr> <tr> <td>E-mail id:</td> <td><input type="text" name="em"></td> </tr> <tr> <td>Phone number:</td> <td><input type="text" name="pn"></td> </tr> <tr> <td>Sex:</td> <td>male<input type="radio">female<input type="radio"></td> </tr> <tr> <td>Date of birth:</td> <td>dd:<select> <option>1 <option>2 <option>3 <option>4 <option>5 <option>6 <option>7 <option>8 <option>9 <option>10 <option>11 <option>12 <option>13 <option>14 <option>15 <option>16 <option>17 <option>18 <option>19 <option>20

For latest technology news visit us at http://www.devilsduke.com

<option>21 <option>22 <option>23 <option>24 <option>25 <option>26 <option>27 <option>28 <option>29 <option>30 <option>31 </select> mm:<select> <option>1 <option>2 <option>3 <option>4 <option>5 <option>6 <option>7 <option>8 <option>9 <option>10 <option>11 <option>12 </select> yy:<select> <option>1981 <option>1982 <option>1983 <option>1984 <option>1985 <option>1986 <option>1987 <option>1988 <option>1989 <option>1990 </select></td> </tr> <tr> <td>Languages known:</td>

For latest technology news visit us at http://www.devilsduke.com

<td>English<input type="checkbox">Telugu<input type="checkbox">hindi<input type="checkbox">Tamil<input type="checkbox"></td> </tr> <tr> <td>Address:</td> <td><textarea rows="5" columns="5"></textarea></td> </tr> <tr> <td><input type="submit" value="submit" onclick="validate()"></td> <td><input type="reset" value="cancel"></td> </tr> </table> </forms> </body> </html>

Output - 1:

For latest technology news visit us at http://www.devilsduke.com

Output - 2:

Output - 3:

For latest technology news visit us at http://www.devilsduke.com

To design a web page using css (cascading style sheets) which includes the following: Use different font, styles: In the style definition you define how each selector should work (color, font etc.,) Procedure: < Css1.html > <html> <head> </head> <style> .myid{ color:red; font-family:"monotype corsiva"; } </style> <body> <form> <p class="myid">login:<input type="text" maxlength="32" size="16"> <p class="myid">password:<input type="password" maxlength="10" size="16"> <br> <input type="submit" value="login"> <input type="reset" value="cancel"> </form> </body> </html>

Set the background image for the page. Procedure: < Css2.html > <html> <head> <title>sample</title> </head> <style> .myid{ color:red; font-family:"monotype corsiva"; } .link{ cursor:value;

For latest technology news visit us at http://www.devilsduke.com

} </style> <body background="C:\Documents and Settings\chaitu\Desktop\22.gif"> <form> <p class="myid">login:<input type="text" maxlength="32" size="16"> <p class="myid">password:<input type="password" maxlength="10" size="16"> <br> <input type="submit" value="login"> <input type="reset" value="cancel"> </form> </body> </html> Output:

For latest technology news visit us at http://www.devilsduke.com

Control the repitition of the image with the background- repeat property Procedure: < Css3.html > <html> <head> <title>sample</title> </head> <style> .myid{ color:red; font-family:"monotype corsiva"; } .link{ cursor:value; } </style> <body background="C:\Documents and Settings\chaitu\Desktop\Glass_Apple.gif"> <form> <p class="myid">login:<input type="text" maxlength="32" size="16"> <p class="myid">password:<input type="password" maxlength="10" size="16"> <br> <input type="submit" value="login"> <input type="reset" value="cancel"> </form> </body> </html>

For latest technology news visit us at http://www.devilsduke.com

Output:

For latest technology news visit us at http://www.devilsduke.com

Working with layers: Procedure: < css4.html > <html> <head> <title> Layers </title> </head> <body> <h1> Layering Text </h1> <div style="z-index: 2; left:50px; top:250px; position: absolute; color:black; text:white"> <p> This is the higher layer </p> </div> <div style="z-index: 1; left:100px; top:225px; position: absolute; font-size=46pt; color:magneta; background-color: green; border: thin groove"> <p> Some more text </p> </div> </div> <div style="z-index: 4; left:10px; top:30px; width:150px position: absolute; backgroundcolor: yellow; color: black; font-size: 18pt;"> <p> Some text placed in a box that doesn't go to right across the scren </p> </div> </div> <div style="position: absolute; top:300px; left:500px; width:25 background-color: #aeae00; color:blue; font-size: 16pt; font-stype:italic; z-index: 2"> <p> And in the bottom right corner... </p> </div> <hr> </body> </html>

For latest technology news visit us at http://www.devilsduke.com

Output:

For latest technology news visit us at http://www.devilsduke.com

Add a customised cursor Procedure: < css5.html > <html> <head> <title>sample</title> </head> <style> .myid{ color:red; font-family:"monotype corsiva"; } .link{ cursor:crosshair; } </style> <body> <form> <p class="myid">login:<input type="text" maxlength="32" size="16"> <p class="myid">password:<input type="password" maxlength="10" size="16"> <br> <input type="submit" value="login"> <input type="reset" value="cancel"> </form> <a href="style.html" class="link">click here</a> </body> </html> Output:

For latest technology news visit us at http://www.devilsduke.com

Write an xml file which will display the book information which includes the following: 1. 2. 3. 4. 5. 6. Title of the book Author name ISBN number Publisher name Edition Price

Write a Document Type Definition (DTD) to validate the above XML file. Procedure:

< booksinfor.dtd >


<!ELEMENT books (book+)> <!ELEMENT book (title,author,ISBN,publisher,edition,price)> <!ELEMENT title (#PCDATA)> <!ELEMENT author (#PCDATA)> <!ELEMENT ISBN (#PCDATA)> <!ELEMENT publisher (#PCDATA)> <!ELEMENT edition (#PCDATA)> <!ELEMENT price (#PCDATA)>

< week5.xml >


<?xml version="1.0"?> <!DOCTYPE books SYSTEM "booksinfor.dtd"> <?xml:stylesheet type="text/xsl" href="bookinf.xsl"?> <books> <book> <title>Web programming,building internet applications</title> <author> ChrisBates</author> <ISBN>0-07-049543-7</ISBN>

<publisher>Wiley Dreamtech</publisher> <edition>2nd edition</edition> <price>Rs.250</price>

For latest technology news visit us at http://www.devilsduke.com

</book> <book> <title>Computer Networks</title> <author> Andrew S Tanebaum</author> <ISBN>81-203-1165-5</ISBN> <publisher>Pearson</publisher> <edition>4nd edition</edition> <price>Rs.350</price> </book> <book> <title>Frontiers of Electronic commerce</title> <author> Kalakata</author> <ISBN>978-81-265-1173-0</ISBN> <publisher>Pearson</publisher> <edition>1st edition</edition> <price>Rs.350</price> </book> <book> <title>Java Programming with CORBA</title> <author> G.Brose</author> <ISBN>978-81-265-1173-0</ISBN> <publisher>Wiley Dreamtech</publisher> <edition>2nd edition</edition> <price>Rs.250</price> </book> <book> <title>The Unified Modelling language User Guide</title> <author>GradyBooch,James Rumbaugh,Ivar Jacabson</author> <ISBN>81-7758-372-7</ISBN> <publisher>Perarson Education</publisher> <edition>2nd edition</edition> <price>Rs.400</price> </book> <book>

<title>Data mining - Concepts and techniques </title> <author> Jiawei HAn and Kamber</author> <ISBN>978-81-312-0538-8</ISBN> <publisher>Pearson</publisher> <edition>1st edition</edition> <price>Rs.550</price>

For latest technology news visit us at http://www.devilsduke.com

</book> </books>

< bookinf.xsl >


<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html"/> <xsl:template match="/"> <html> <body> <table align="center" cellspacing="5" cellpadding="10"> <caption>BOOKS INFORMATION</caption> <tr bgcolor="light brown "> <th>Title</th> <th>Author</th> <th>ISBN</th> <th>Publisher</th> <th>Edition</th> <th>Price</th> </tr> <xsl:for-each select="books/book"> <tr> <td> <xsl:value-of select="title"/></td> <td> <xsl:value-of select="author"/></td> <td> <xsl:value-of select="ISBN"/></td> <td> <xsl:value-of select="publisher"/></td> <td> <xsl:value-of select="edition"/></td> <td> <xsl:value-of select="price"/></td> </tr>

</xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>

For latest technology news visit us at http://www.devilsduke.com

Output:

For latest technology news visit us at http://www.devilsduke.com

Visual beans: Create a sample visual bean with an area filled with a color. < Colors1.java > package sunw.demo.colors1; import java.awt.*; import java.awt.event.*; public class Colors1 extends Canvas { transient private Color color; private boolean square; public Colors1() { addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent me) { change(); } } ); square=false; setSize(200,200); change(); } public boolean getSquare() { return square; } public void setSquare(boolean flag) { this.square=flag; repaint(); }

public void change() { color=randomColor(); repaint(); }

For latest technology news visit us at http://www.devilsduke.com

private Color randomColor() { int r=(int)(255*Math.random()); int g=(int)(255*Math.random()); int b=(int)(255*Math.random()); return new Color(r,g,b); } public void paint(Graphics g) { Dimension d=getSize(); int h=d.height; int w=d.width; g.setColor(color); if(square) { g.fillRect(0,0,w-1,h-1); } else { g.fillOval(0,0,w-1,h-1); } } } < colors1.mft > Name: sunw/demo/colors1/Colors1$1.class Name: sunw/demo/colors1/Colors1.class Java-Bean: True

Command Prompt Instructions: Z:\beans>cd demo Z:\beans\demo>javac sunw\demo\colors1\colors1.java Z:\beans\demo>jar -cvfm ..\jars\colors1.jar colors1.mft sunw\demo\colors1\*.class Z:\beans\demo>cd .. Z:\beans>cd beanbox Z:\beans\beanbox>run.bat

For latest technology news visit us at http://www.devilsduke.com

Output - 1:

Output - 2:

For latest technology news visit us at http://www.devilsduke.com

1) To Install TOMCAT web server and APACHE. While installation assign port number 4040 to TOMCAT and 8080 to APACHE. Make sure that these ports are available i.e., no other process is using this port. PROCEDURE: 1) First install the tomcat in to the system. 2) Set the JAVA_HOME at the java development kit installed location. C:\program Files\ Java\jdk1.7.0. 3) Set the CATALINA_HOME C:Program Files\Apache Software Foundation\Tomcat 7.0 4) To compile the servlet programs and to recognize javax packages set the CLASSPATH to servlet-api.jar, this file contains implementation for servlet API specific to tomcat vendors. C:Program Files\Apache Software Foundation\Tomcat 7.0\lib\servlet-api.jar;

2) Access the static web pages for books web site, using these servers by putting the web pages in the document root.

Output:

For latest technology news visit us at http://www.devilsduke.com

User authentication: Assume for 4 users and their passwords 1. Create a cookie and add these four user ids and passwords to this cookie 2. Read the user id and passwords entered in the login form and authenticate with the values available in the cookies. < UserAuthentication.java > import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; public class UserAuthentication extends HttpServlet { Enumeration en; ServletConfig sc; Cookie c[]=new Cookie[4]; public void init(ServletConfig sc) throws ServletException { this.sc=sc; en=sc.getInitParameterNames(); } public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException { int i=0; while(en.hasMoreElements()) { String name=(String)en.nextElement(); String value=sc.getInitParameter(name) ;

c[i]=new Cookie(name,value); c[i].setMaxAge(60*60*24*7); res.addCookie(c[i]); i++; } PrintWriter pw=res.getWriter(); pw.println("<html>"); pw.println("<head><title>Login form</title></head>"); pw.println("<body><form action=./login method=post>");

For latest technology news visit us at http://www.devilsduke.com

pw.println("Login name <input type=text name=username><br> password <input type=password name=password>"); pw.println("<input type=submit value=signin>"); pw.println("</form></body>"); pw.println("</html>"); } public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException { Cookie c[]=req.getCookies(); res.setContentType("text/html"); PrintWriter out=res.getWriter(); String un=req.getParameter("username"); String pw=req.getParameter("password"); int flag=0; for(int i=0;i<4;i++) { if(c[i].getName().equals(un) &&c[i].getValue().equals(pw)) { out.println("welcome to"+un); flag=1; break; } } if(flag==0)

{ out.println("not an authenticated user"); } out.close(); } } Web.xml: <web-app> <servlet> <init-param> <param-name>aruna</param-name> <param-value>1206</param-value> </init-param> <init-param>

For latest technology news visit us at http://www.devilsduke.com

<param-name>asrutha</param-name> <param-value>1200</param-value> </init-param> <init-param> <param-name>mahi</param-name> <param-value>1201</param-value> </init-param> <init-param> <param-name>madhu</param-name> <param-value>1202</param-value> </init-param> <servlet-name>UA</servlet-name> <servlet-class>UserAuthentication</servlet-class> </servlet> <servlet-mapping> <servlet-name>UA</servlet-name> <url-pattern>/login</url-pattern> </servlet-mapping> </web-app>

Z:\wt_lab\week8\WEB-INF\classes>javac UserAuthentication.java Z:\wt_lab\week8>jar -cvf user6.war *.* added manifest

For latest technology news visit us at http://www.devilsduke.com

OUTPUT - 1:

OUTPUT - 2:

For latest technology news visit us at http://www.devilsduke.com

Install a database (MySQL or Oracle). Create a table which should contain at least the following fields: name, password, email-id, Phone number (these should hold the data from the registration form). Write a java program/servlet/JSP to Insert the details of the users who register with the web site, whenever a new user clicks the submit button in the registration page (week2). Reg.html: <html> <head> <title> validation </title> </head> <body bgcolor="magenta"> <form action="Register.jsp" method="post"> <h1 align="center">REGISTRATION FORM</h1> <table border="0"> <tr> <td>Name:</td> <td><input type="text" name="t1" min length="6"></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="t2"></td> </tr> <tr> <td>Phone number:</td> <td><input type="text" name="t3"></td> </tr> <tr> <td>E-mail id:</td> <td><input type="text" name="t4"></td> </tr> <tr> <td><input type="submit" value="submit"></td> <td><input type="reset" value="cancel"></td> </tr> </table> </form> </body> </html>

For latest technology news visit us at http://www.devilsduke.com

Register.jsp: <%@ page language="java" import="java.sql.*,javax.servlet.*" %> <html> <form > <% String v1,v2,v3,v4,str; v1=request.getParameter("t1"); v2=request.getParameter("t2"); v3=request.getParameter("t3"); v4=request.getParameter("t4"); try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection cn=DriverManager.getConnection("jdbc:odbc:oradsn","scott","tiger"); Statement st=cn.createStatement(); st.executeUpdate("insert into register values('"+v1+"','"+v2+"',"+v3+",'"+v4+"')"); if(cn!=null) { %> </form> Registration Successful <% } else { out.println("Registration failed"); } st.close(); cn.close(); }catch(Exception e) { out.println(" Registration failed"); %> <P><a href = "reg.html" target =f2 > <B> Back<B> </a> <% } %> </body></html>

For latest technology news visit us at http://www.devilsduke.com

Execution: Create a table with name register with name (varchar2 (10)), password (varchar2 (10)), Phone(number (10)) ,Email-ID (varchar2(10)). Create the Data source name. Start->settings->control panel->Administrative Tools->Data Sources. Under SystemDSN add Microsoft ODBC for Oracle. Set Data Source name to oradsn. Output:

For latest technology news visit us at http://www.devilsduke.com

Write a JSP which does the following job: Insert the details of the 3 or 4 users who register with the web site (week9) by using registration form. Authenticate the user when he submits the login form using the user name and password from the database. Login.html: <html> <head> <title> login page </title> </head> <body bgcolor="cyan"> <center> <right> <form action="valid.jsp" method="post" > <h4>username<input type="text" name="t1"> <h4>password <input type="password" name="t2" > <br><br> <input type="submit" value="submit"> <input type="reset" value="reset"></form> </body> </html> Valid.jsp: <%@ page language="java" import="java.sql.*,javax.servlet.*" %> <html> <form> <% int v=0; String v1,v2,v3,v4,str; v1=request.getParameter("t1"); v2=request.getParameter("t2"); try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection cn=DriverManager.getConnection("jdbc:odbc:oradsn","scott","tiger"); Statement st=cn.createStatement(); ResultSet rs=st.executeQuery("select * from register");

For latest technology news visit us at http://www.devilsduke.com

while(rs.next()) { if(rs.getString(1)==v1 && rs.getString(2)==v2) { v=1; } } if(cn!=null && v==1) { %> </form> Login Successfull <% } else { out.println("Login failed"); } st.close(); cn.close(); }catch(Exception e) { out.println("Error Occured. \n Login failed"); %> <P><a href = "login.html" target =f2 > <B> Back<B> </a> <% } %> </body></html>

For latest technology news visit us at http://www.devilsduke.com

Output:

You might also like