Jntu web technologies record manual for engineering students
Upcoming SlideShare
Loading in...5
×
 

Jntu web technologies record manual for engineering students

on

  • 215 views

 

Statistics

Views

Total Views
215
Views on SlideShare
215
Embed Views
0

Actions

Likes
0
Downloads
2
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft Word

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Jntu web technologies record manual for engineering students Jntu web technologies record manual for engineering students Document Transcript

  • JNTU WEB TECHNOLOGIES RECORD MANUAL FOR ENGINEERING STUDENTSWeek-1Aim: To design the following static web pages required for an online book store website. HOME PAGE The static home page must contain three frames. Top frame: Logo and the college name and links to home page, login page, registration page. Catalogue page and Cart page (the description of these pages will be given below). Left frame: At least four links for navigation, which will display the catalogue of respective links. For e.g. when you click the link “CSE” the catalogue for CSE book should be displayed in the Right Frame. Right frame: The page to the link in the left frame must be loaded here. Initially this page contains description of the website. Program: frame1.html <html> <head> <title>frame</title> </head> <frameset rows=”25,*”> <frame src=”topframe.html” scrolling=”no”> <frameset cols=”10 %,*”> <frame src=”leftframe.html”> <frame src=”rightframe.html” name=”xyz”> </frameset> </frameset> </html> topframe.html <html> <head> <title>topframe</title> </head> <body bgcolor=”grenn”> <table width=”100%” align=”center” cellspacing=”0”> <tr> <th><img width=”100” height=100 src=”c:.......image url……….paste……></th> <th colspan=5><h1 font color=”skyblue”>……….COLLEGE NAME………..</font></h1> <tr>
  • <th> <a href=”home.html”target=”xyz”><h3>HOME </a></h3><th> <a href=”login.html”target=”xyz”><h2> </a>LOGIN</h2><th> <a href=”registration.html”target=”xyz”><h2>REGISTRATION</a></h2><th> <a href=”catalogue.html”target=”xyz”><h2>CATALOGUE </a></h2><th> <a href=”cart.html”target=”xyz”><h2> CART</a></h2></tr</table></body></html>rightframe.html<html><head><title>rightframe</title><body bgcolor=”mediumorchid”><p><i><font color=”white” width=”5”>……………..Just you have to write about your college in this area……………..</body></html>leftframe.html<html><head><title>leftframe</title><body bgcolor=”red”><a href=”cse.html”target=”xyz”><font color=”white” width=”3”>CSE</a><br><br><a href=”ece.html”target=”xyz”><font color=”white” width=”3”>ECE</a><br><br><a href=”civil.html”target=”xyz”><font color=”white” width=”3”>CIVIL</a><br><br><a href=”eee.html”target=”xyz”><font color=”white” width=”3”>EEE</a><br><br></head></body><html>cse.html<html><head><title>cse</title></head><body><p>……………….Write the content about CSE……………………….</p>
  • </body></html>ece.html<html><head><title>ece</title></head><body><p>……………….Write the content about ECE……………………….</p></body></html>civil.html<html><head><title>civil</title></head><body><p>……………….Write the content about CIVIL……………………….</p></body></html>eee.html<html><head><title>eee</title></head><body><p>……………….Write the content about EEE……………………….</p></body></html>LOGINAIM: To design the following static webpage to display login page.
  • Program:<html><head><title> New Document</title></head><body leftmargin=”300”><br><br><br><br><br><br><br><pre>Name :<input type=”text” value=”” size=”20”><br>Password :<input type=”password” value=”” size=”20”><br> <input type=”submit” value=”submit” size=”20”><br> <input type=”reset” value=”reset” size=”20”></pre></body></html>CATALOGUE PAGEThe catalogue page should contain the details of all the books available in the website in a table.The details should contain the following: 1. Snapshot of cover page 2. Author name 3. Publisher 4. Price 5. Add to cart buttonProgram:catalogue.html<html><head><title>catalogue</title></head><body bgcolor=”lightgreen”><table colspan=”4” width=”100%” align=”center”><tr><td><img width=”50” src=”………….paste the image url………….”>
  • <td>book: …..Name…….<br> Author:…Name…<br> Publication:…Name…. <td>$...price…<input typr=”reset” value=”add to cart”> </tr> <tr> <td><img width=”50” src=”………….paste the image url………….”> <td>book: …..Name…….<br> Author:…Name…<br> Publication:…Name…. <td>$...price…<input typr=”reset” value=”add to cart”> </tr> <tr> <td><img width=”50” src=”………….paste the image url………….”> <td>book: …..Name…….<br> Author:…Name…<br> Publication:…Name…. <td>$...price…<input typr=”reset” value=”add to cart”> </tr> <tr> <td><img width=”50” src=”………….paste the image url………….”> <td>book: …..Name…….<br> Author:…Name…<br> Publication:…Name…. <td>$...price…<input typr=”reset” value=”add to cart”> </tr> </table> </html>WEEK-2 CART PAGE Aim: To write a program to display the cartpage contains the details about the book which are added to cart. Program: cart.html <html> <head> <title>cart</title> </head> <body>
  • <table><tr><td><tr><td>…Book Name…<th>$...Book Price…<td>$...Total Price…></tr><tr><td>…Book Name…<th>$... Book Price…<td>$...Total Price …></tr><tr><td>…Book Name…<th>$... Book Price…<td>$...Total Price …></tr><tr><td>…Book Name…<th>$... Book Price…<td>$...Total Price …></tr><tr><td><td><td>Total Amount<td>…………..------…………..</tr><br></table></body></html>Registration PageAim: To create a Registration page with the following fields 1. Name(text field) 2. Password(password field) 3. E=mail(text field) 4. Phone number(text field) 5. Sex(radio button) 6. Date of birth(3 select boxes) 7. Languages known(check-boxes) 8. Address(text area)Program:registration.html<html><head><title>registration</title></head><body bgcolor=”lightblue”>,table width=”90%”><tr><td><pre> Name :<input type=”text” value=” ” size=”20”><tr></pre><tr><td><pre>E-mail :<input type=”text” value=” ” size=”30”><tr></pre><tr><td><pre>Password :<input type=”password” value=” ” size=”10”><tr></pre><tr>
  • <td><pre>Gender :<input type=”radio” name=”r1”>Male<input type=”radio”name”r1”>Female<tr></pre></tr><tr><td><pre>Languages Known: <input type=”checkbox” name=”Telugu”>Telugu<inputtype=”checkbox” name=”HIndi”>HIndi<input type=”checkbox” name=”English”>English<inputtype=”checkbox” name=”Tamil”>Tamil<input type=”checkbox” name=”OtherLanguages”><tr></pre><tr><td><pre> D.O.B <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<option>21<option>22<option>23<option>24<option>25<option>26<option>27<option>28<option>29<option>30<option>31</select> <select>
  • <option>Jan<option>Feb<option>Mar<option>Apr<option>May<option>Jun<option>Jul<option>Aug<option>Set<option>Oct<option>Nov<option>Dec</select> <select><option>1975<option>1976<option>1977<option>1978<option>1979<option>1980<option>1981<option>1982<option>1983<option>1984<option>1985<option>1986<option>1987<option>1988<option>1989<option>1990<option>1991<option>1992<option>1993<option>1994<option>1995<option>1996<option>1997<option>1998<option>1999<option>2000<option>2001<option>2002<option>2003
  • <option>2004 <option>2005 <option>2006 <option>2007 <option>2008 <option>2009 <option>2010 <option>2011 <option>2012 </select> </tr></pre> <tr> <td><pre>Address :<textarea value=”” rows=”3” cols”10”></textarea> <pre><input type=”submit” value=”submit” size=”20”> <input type=”reset” value=”reset” size=”20”> </pre> </tr></pre> <table> </body> </html>WEEK-3 VALIDATION: Registration Page Aim: To write a java Script to validation the following fields of registration page. 1. Name(name should contain alphabets and the length should be less than 6 characters) 2. Password(Password should contain alphabet and the symbol not less than 6) 3. E-mail id(should not contain any invalid and must follow the standard pattern) 4. Phone number(should contain 10 digits only) Program: Valreg.html <html> <head> <script language=”javascript”> Function validation() { var s1=f1.t1.value; var s2=f1.t2.value; var s3=f1.t3.value; var s4=f1.t4.value; var ex1=new RegExp(“^ *i a-z++$”);
  • var ex2=new RegExp(“^ *i A-Z0-9 + ,6-+$”); var ex3=new RegExp(“^ *0-9+ ,10-$”); var ex4=new RegExp(“^ *A-Z a-z].+[A-Z a-z 0-9] +.@[a-z]+.[a-z]{3}$”); if(ex1.exec(s1)){} else,alert(”invalid name”);- if(ex2.exec(s2)){} else,alert(“invalid password”);- if(ex3.exec(s3)){} else,alert(“invalid phone number”);- if(ex4.exec(s4)){} else,alert(“invalid e-mail id”);-}</script><body><form action=”ex.html name=”f1” method=”post” onsubmit=”validation()”> Name :<input type=”text” size=”10 ” name=”t1”><br>Password :<input type=”password” name=”t2 ”><br>Phone number :<input type=”text” size=”10” name=”t3”><br>E-mail :<input type=”text” size=”20 ”name=”t4”><tr><br><pre><input type=”submit” value=”submit” size=”20”><input type=”reset value=”reset” size=”20”></pre></form></body></html>VALIDATION: Login PageAim: To write a java script to validate the following fields of login page. 1. User name(should contain alphabet, no less than 6) 2. Password(should not be less than 6 characters)Program:login.html<html><head><script language=”javascript”>function login(){ var s1=f1.t1.value; var s2=f1.t2.value; var ex1=new RegExp(“^ *i a-z++$”); var ex2=new RegExp(“^ *i A-Z0-9 + ,6-+$”); if(ex1.exec(s1)){}
  • else,alert(”invalid name”);- if(ex2.exec(s2)){} else,alert(“invalid password”);- } </script> <body> <form action=”ex.html name=”f1” method=”post” onsubmit=”validation()”> Name :<input type=”text” size=”10 ” name=”t1”><br> Password :<input type=”password” name=”t2 ”><br> <pre><input type=”submit” value=”submit” size=”20”> <input type=”reset value=”reset” size=”20”></pre> </form> </body> </html>WEEK-4 Cascading Style Sheets Aim: To design a webpage using CSS(cascading style sheet) which includes the following Use different font, style In the style definition you define how each selector should work (font, clor, etc). Then in the body of your pages, you refer to these selectors to activate the styles. To design a page includes Set a background image for both the page and single element on the page. We can define the background image for the page like BODY{background-image : Url (my image.gif);} To design a page includes Control the repetition of the image with the background repeat property. As background repeat:repeat. Tiles the image until the entire page is filled, just like an ordinary background image in plain HMTL. To design a page includes Define styles for links as A:link A:visited A:active A:hover To design a page that includes work with layers. To design a page includes Add a customized cursor Selector{cursor:value}
  • Program:<html><head><title>stylesheet</title><style type=”text/css”>B.headline { color:red; font-size:22px; font-family:arial; text-decoration:underline; }.xlink {cursor:crosshair;}.hlink {cursor:help;}body {background-image:url (“C:Documents and settingsPcMy Documents123.jpg”);background-repeat:repeat;}a:link{text-decoration:none;}a:visited{text-decoration:pink;}a:active{text-decoration:blue;}a:hover{ text-decoration:underline;color:red;}</style></head><body><B>This is WT lab<B></br><a href=”MBA.html” class=”xlink”>crosslink</a><a href=”M.Tech.html” class=”hlink”>helpline</a><B class=”Headline”>Displaying Web Page</B>Layer1 on <divStyle=”position:absolute”;font-size:50px;top:30;z-index:2>layer1</div><br>Layer2 on <divStyle=”position:absolute”;font-size:50px;color:red;left:5;top:25;z-index:2>layer2</div></body></html>
  • Week -5 XML FILE AIM: To write an XML file which will display the book information which includes the following 1. Title of the book 2. Author Name 3. ISBN Number 4. Publisher Name 5. Edition Name 6. Price Write a documenttype definition (DTD) to validate the above XML file Program: book.dtd <!--Program:book.dtd--> <?xml version=”1.0” encoding=”UTF-8”?> <!ELEMENT booklist (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)> Program: bookdtd.xml <!--program:bookdtd.xml--> <?xml version=”1.0”?> <!DOCTYPE booklist SYSTEM “book:dtd”> <booklist> <book> <title>xml bible</title> <author>Winston</author> <isbn>87499</isbn> <publisher>wiely</publisher> <edition>fifth edition</edition> <price>$63</price> </book> <book> <title>ai</title> <author>s.Russel</author> <isbn>87494</isbn> <publisher>pinceton hall</publisher> <edition>sixth edition</edition> <price>$63</price>
  • </book> <book> <title>java2</title> <author>Watson</author> <isbn>87432</isbn> <publisher>bpb publications</publisher> <edition>third edition</edition> <price>$63</price> </book> <book> <title>Html in 24 hours</title> <author>sam peter</author> <isbn>87492</isbn> <publisher>sam publications</publisher> <edition>fifth edition</edition> <price>$50</price> </book > </booklist>Write an XML schema to validate the above XML file.Program:book.xsd<!--program:book.xsd--><?xml version=”1.0”?><xs:schema xmlns=http://www.w3.org/2011/XTML Schema><xs:element name=”booklist”><xs:complextype><xs:sequence><xs:element name=”title” type=”xs:string”/>< xs:element name=”author” type=”xs:string”/>< xs:element name=”isbn” type=”xs:string”/>< xs:element name=”publisher” type=”xs:string”/>< xs:element name=”edition” type=”xs:string”/>< xs:element name=”price” type=”xs:integer”/></xs:sequence></xs:complextype></xs:element></xs:sequence></xs:complextype></xs:element></xs:schema>Program:bookxsd.xml <?xml version=”1.0”?> <booklist xmlns:xsi=”http”//www.w3.org/2001/xml schema-instance”xsi:noNameSpaceschemaLocation=”book.xsd”> <book>
  • <title>xml bible</title> <author>Winston</author> <isbn>87499</isbn> <publisher>wiely</publisher> <edition>fifth edition</edition> <price>$63</price> </book> <book> <title>ai</title> <author>s.Russel</author> <isbn>87494</isbn> <publisher>pinceton hall</publisher> <edition>sixth edition</edition> <price>$63</price> </book> <book> <title>java2</title> <author>Watson</author> <isbn>87432</isbn> <publisher>bpb publications</publisher> <edition>third edition</edition> <price>$63</price> </book> <book> <title>Html in 24 hours</title> <author>sam peter</author> <isbn>87492</isbn> <publisher>sam publications</publisher> <edition>fifth edition</edition> <price>$50</price> </book > </booklist>Display the XML file as follows( XML Using XSL)Program:book.xsl<!—program:book.xsl--><?xsl:stylesheet version=”1.0”xmlns:xsl=”http://www.w3.0rg/1999/XSL/Transform’<xsl:template match=”/”><html><body><center><h2><font color=”#7788ee”>BOOKS INFORMATION</font></h2><table border=”1”><thead bgcolor=”#446677”><tr><th>title</th><th>author</th>
  • <th>isbn</th><th>publisher</th><th>edition</th><th>price</th></tr></thead><xsl:for-each select=”booklist/book”><tr><td><font color=”blue”><xsl:value-of select=”title”/></font></td><td><font color=”RED”><B><xsl:value-of select=”translate(author,’abcdefghijklmn)<td><font color=”blue”><xsl:value-of select=”isbn”/></font></td><td><font color=”blue”><xsl:value-of select=”publisher”/></font></td><td><font color=”blue”><xsl:value-of select=”edition”/></font></td><td><font color=”blue”><xsl:value-of select=”price”/></font></td></tr></xsl:for-each></table></center></body></html><xsl:template></xsl:stylesheet>Program:book.xml<!--program:book.xml--><?xml version=”1.0”?><?XML-Stylesheet type=”text/xsl”href=”book.xsl”?><booklist><book><title>xml bible</title><author>Winston</author><isbn>87499</isbn><publisher>wiely</publisher><edition>fifth edition</edition><price>$40.5</price></book><book><title>ai</title><author>s.Russel</author><isbn>87494</isbn><publisher>priceton hall</publisher><edition>sixth edition</edition><price>$63</price></book><book><title>java2</title><author>Watson</author>
  • Isbn>87422</isbn><publisher>bpb publications</publisher><edition>third edition</edition><price>$63</price></book><book><title>Html in 24 hours</title><author>sam peter</author><isbn>87492</isbn><publisher>sam publications</publisher><edition>fifth edition</edition><price>$50</price></book ></booklist>Week-6Creating a New Bean: To create a simple visual bean with area filled with a color. The shape of the area depends on the property shape. If it isset to true then the shape of the area is square and it is circle if it is false. The color of the area should be changed dynamically for every mouse click. The color should also be changed if we change the color in the property window.Program:Colors.javapackage sunw.demo.colors;import java.awt.*;import java.awt.event*;public class Colors extends Canwas{ transient private Color color; private boolean rectangular; public Colors() { addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent me) { change(); } }); rectangular=false; setSize(200,100); change(); } public boolean getRectangulat() { return rectangular;
  • } public void setRectangular(boolean flag) { this.rectangular=flag; repaint(); } public void change() { color=randomColor(); repaint(); } 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(Grapics g) { Dimention d=getSize(); int h=d.height; int w=d.width; g.setColor(color); if(rectangular) { g.fillRect(0,0,w-l,h-l); } else { g.fillOval(0,0,w-1,h-1); } }}WEEK-7Installation Of TomcatAim: To write the installation procedure for Tomcat web server and APACHE and while installing use theport number as 8080.
  • Week-8User AuthenticationAIM: Assume four users user1, user2, user3 and users having passwords pwd1, pwd2, pwd3&pwd4 respectively. Write a servlet for doing the following: 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 (user id and passwords) available in the cookies. If be is a valid user (i.e., username and password match) you should Welcome him by name (user-name) else you should display “you are not an authenticated user.Program:cookies.html<html><head></head><body bgcolor=”pink”><from action=”./cc” method=”get”><center><br><h3>WELCOME TO COOKIES WROLD!</h3><br>Uname&ndsp&ndsp&ndsp&ndsp&ndsp:<input type=”text” name=”t1”<br><br><br>Password:<input type=”password” name=”t2”><br><br><br><input type=”submit” value=”AddCookies”><br><br></form><form action=”./ch” method=”get”><center><br><h3>!@ Login Page @!<?h3><br>Uname&ndsp&ndsp&ndsp&ndsp&ndsp:<input type=”text” name=”user”<br><br>Password:<input type=”password” name=”pwd”><br><br><input type=”submit” value=”Login”><br><br></form></center></body><html>Program:AddCookie.javaimport java.io.*;import javax.servlet.*;import javax.servlet.http.*;public class AddCookie extends HttpServlet{ Public void doGet(HttpServletRequest req,HttpServletResponse res)throws IOException,ServletException
  • { res.setContentType(“text/html”); String name=req.getParameter(“t1”); String value=req.getParameter(“t2”); PrintWriter out=res.getWriter(); If((!value.equals(“”))&&(!name.equals(“”))) { Cookie c=new Cookie(name.value); res.addCookie(c); out.println(“<body bgcolor=cyan><p align=center>Cookie is Added:”); out.println(“<a href=”./cc.html>To Add A New Cookie</a></p>”); out.println(“<p align=center><a href=./view>View<?a><?p></body>”); } else { out.println(“Cookie is Not Executed”); out.println(“<a href=./cc.html>Click Here to Add Cookie</a>”); } }}Program:ValidCooki.javaimport java.io.*;import javax.servlet.*;import javax.servlet.http.*;public class ValidCookie extends HttpServlet{ Public void doGet(HttpServletRequest req,HttpServletResponse res)throws IOException,ServletException { res.setContentType(“text/html”); String name1=req.getParameter(“user”); String value1=req.getParameter(“pwd”); PrintWriter out=res.getWriter(); Cookie c[]=req.getCookie(); if(c!=null) { for(int j=0;j<c.length;j++) { if((c[j].getName()).equals(name1)) {
  • if((c[j].getValue()).equals(value)) { out.println(“Authorised User”); out.println(“Welcime”+name1+”to Cookies”); } else out.println(“<font color=red> Invalid Password</font>”); } else out.println(font color=gray>Unauthorised User</font>”); } } else out.println(“No cookies are added”); out.close(); }}Program:View.javaimport java.io.*;import javax.servlet.*;import javax.servlet.http.*;public class View extends HttpServlet{ Public void doGet(HttpServletRequest req,HttpServletResponse res)throws IOException,ServletException { PrintWriter out=res.getWriter(); Cookie c[]=req.getCookie(); if(c!=null) { out.println(“<html><body bgcolor=cyan>”); out.println(“<h2 align=center>The Cookies added are</h2>”); out.println(“<table border=1 align=center><tr><ht>name</th> <th>value</th></tr>”); for(int i=0;i<c.length;i++) { out.println(“<tr><td>”+c*i+.getName()+”</td>”); out.println(“<td>”+c*i+.getValue()+”</td></tr>”); } }
  • out.println(“</table></body></html>”); out.close(); }}Program:Web.xml<web-app><servlet><servlet-name>c</servlet-name><servlet-class>AddCookies</servlet-class></servlet><servlet-mapping><servlet-name>c</servlet-name><url-pattern>/cc</url-pattern></servlet-mapping><servlet><servlet-name>ch</servlet-name><servlet-class>ValidCookies</servlet-class></servlet><servlet-mapping><servlet-name>ch</servlet-name><url-pattern>/ch</url-pattern></servlet-mapping><servlet><servlet-name>views</servlet-name><servlet-class>View</servlet-class></servlet><servlet-mapping><servlet-name>views</servlet-name><url-pattern>/view</url-pattern></servlet-mapping><web-app> INIT Parameters Aim: Use init parameters to the following: Store the username and password in the web.xml and access them in the servlet by using the following getInit Parameter () Initialization parameters are set in the deployment descriptor. To supply the data to the servlet at the runtime of initialization of the servlet. We use initialization parameters. So, the servlet can access this data during the runtime.
  • Program:Web.xml<web-app><servlet><servlet-name>init</servlet-name><servlet-class>initParameters</servlet-class><init-param><param-name>ul</param-name><param-value>anil</param-value></init-param></init-param><param-name>u3</param-name><param-value>giri</param-value></init-param><init-param><param-name>u4</param-name><param-value>nag</param-value></init-param><init-param><param-name>u5</param-name><param-value>suneel</param-value></init-param><init-param><param-name>u6</param-name><param-value>laitha</param-value></init-param></servlet><servlet_mapping><servlet-name>init</servlet-name><url-pattern>/init</url-pattern></servlet-mapping></web-app>Program:InitParameters.Javaimport java.io.*;import javax.servlet.*;import javax.servlet.http.*;public class initParameters extends HttpServlet{ public void doGet (HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException
  • { res.setContentType(“text/html): PrintWriter out=res.getWriter(); out.println(“initParameters are”); ServletConfig sc=getServletConfig(); Enumeration e=sc.getInitParameterNames(); out.println(“html><body bgcolon=cyan>”); out.println(“<h1>welcome to init parameters</h1>”); //out.println(“<form action=./init name=f1”); //out.println(“<input type=”submit” value= to view init parametersclick>”); out.println(“<boby><html>”); While(e.hasMoreElements()) { String name=(string)e.nextElement(); Out.println(“<br>”+sc.getinitParameter(name)); } }}WEEK 9 Inserting values into Registration page AIM: Install a database (my sql or oracle) Create a table which should contain at least the following field: Name, password, email_id, phone number. Practice “JDBC” connectivity. Write a java program [servlet] jsp to connect to that database and extract data from the tables and display them. Experiments with value various sql queries. Insert the details of the uses who register with the website, wherever a new user click the submit button in the registration page.Program:Reg.html<html><head><title>validation</title></head><form action=”./reg” method=”post”><body bgcolor=”magenta”><h1 align=”center”>registration form</h1><table border=”0”><tr><td>name:</td><td>input type=”test” name=”user” minlength=”6”></td>
  • </tr><tr><td>password:</td><td><input type=”text” name=”ph”</td></tr><tr><td>email id:</td><td>input type=”text” name=”email”></td></tr><tr><td><input type=”submit” value=”submit”></td></tr></table></form></body></html>Program:Reg.servlet.javaimport java.io.*;import javax.servlet.*;import javax.servlet.http.*;public class RegServlet extends HttpServlet{ public void doGet(HttpServletRequest req,HttpServletResponse res)throws IOException,ServletException { PrintWriter out=res.getWriter(); try { String u=req.getParameter (“user”); String p=req.getParameter (“pwd”); String ph=req.getParameter(“ph”); String e=req.getParameter(“email”); res.setContentType(“text/html”); Class.fornName(“sun.jdbc.odbc.jdbcOdbcDriver”) Connection con =DriverManager.getConnection(“jdbc:odbc:rsr”,””,””); Statement st=con.createStatement(); String str=(“insert into reg values(‘“+u+”’,’”+p+”’,’”+ph+”’,’”+e+”’)”); int x=st.executeUpdate(str); out.println(“<html><body>inserted successfully</body><html>”); } catch(Exception e) {
  • out.println(e); } }}Program:web.xml<web-app><servlet><servlet-name>insert</servlet-name><servlet-class>RegServlet</servlet-class></servlet><servlet-mapping><servlet-name>insert</servlet-name><url-pattern>/reg</url-pattern></servlet-mapping></web-app>WEEK10 JSP Authentication AIM: Write a Jsp which does the following job: Insert the details of the 3 or 4 uses who register with the website (week9) by using registration form. Authernticate the user when he submits the login form using the user name and password from the database(similar to week8 instead of cookies).Programregis.jsp<%@page import “java.io.*.java.sql.*”%><%response.setContentType (“text/html”);String name=request.getParameter (“name”);String password=request.getParameter(“pass”);String email=request.getParameter(“email”);String phoneno=request.getParameter(‘phone”);Class.forName(“sun.jdbc.odbc.jdbcodbcDriver”);Connection con=DriverManager.getConnection(“jdbc:odbc:student”,””,””);Statement st=con.createStatement();String str=”insert into reg values(‘”+name+”’,’”+password+’”,’”+email+”’,’”+phoneneo+”’)”;St.executeUpdate(str);String str1=”insert into login values(‘”+name+”’,’”+password+”’)”;st.executeUpdate(str1);
  • out.println(“Insert Sucessfully”);st.close();con.close();%>Program:Regi.html<html><head><title>Registration</title></head><body bgcolor=”cyan”><form name=”f1” action=”./regis.jsp” align=center”><h2 align=”center”>Registration page</h2><fieldset>8<legend>Registration</legend><table align=”center”><tr><td>Name</td><td><input type=”text” name=”name” size=”10”/></td></tr><tr><td>Password</td><td><input type=”password” name=”pass” size=”10”/></td></tr><tr><td>e-mail</td><td><input type=”text” anme=”email” size=”10”/></td></tr><tr><td>phone no</td><td><input type=”text” name=”phone” size=”10”/></td></tr><tr><td colspan=2 align=”center><input type=”submit” name=”submit” value+”Registration”/></td></tr></table></fieldset></from></body></html>
  • Program:Login.jsp<%@page import “java.io.*.java.sql.*”%><%response.setContentType(“text/html”);String name=request.getParameter(“name”);String password=request.getParameter(“pass”);Class.forName(“sun.jdbc.odbc.jdbcodbcDriver”);Connection con=DriverManager.getConnection(“jdbc:odbc:student”,””,””);preparedStatement ps=con.prepareStatement(“select password from login where name=?”);ps.setString(1,name);ResultSet rs=ps.executeQuery();if(rs.next()){ if(rs.getString(1).equals(password)) ouot.println(“welcome to”+name); else outprintln(“Invalid Password”);}elseout.println(“<font color=red>”+name+”UnAuthorised</font>”);ps.close();con.close();%>Program:Login.html<html><head><title>Login Page</title></head><body bgcolor=”magenta”><h2 align=”center”>Login Page</h2><form name=+login” action=”./login.jsp”><fieldset><legend>Login</legend><table align=”center”><tr><td>Name</td><td><input type=”text” name=”name” size”10”/></td></tr><tr>
  • <td>Password</td><td><input type=”password” name=”pas” size”10”/></td></tr><tr><td colspan=”2” align=”center”><input type=”submit” name=”submit” value=”Login”/></td></tr></table></form></fieldset></body></html>