AIM

:

1. Develop static pages (using Only HTML) of an online Book store.The pages should resemble:www.amazon.com.The website should consists the following pages.
• • • • Home page Registration User Login Books catalog

PROCEDURE: Main page:
<html> <head> <title>home page</title> </head> <body> <center><b><h1>welcome to amazon.com</h1></b><br><br> <form method="post"action="login.html"> <input type="submit"value="click">registration user login hear </center> </body> </html>

Login page: <html> <head> <title>login page</title> </head> <body> <center> <form method="post" action="login.html"> <p><strong>name:</strong> <input type="text" name="username" size="25"> </p> <p><strong>password</strong> <input name="pass" type="password" size="6"></p> <p><strong>male</strong> <input type="radio" value="male"<hacked>&nbsp&nbsp</p> <p><strong>female</strong> <option><input type="radio" value="female"<hacked>&nbsp;</p> <input type="submit" value="submit">&nbsp&nbps <input type="reset" value="reset"> <a href="registration.html">new users register hear </a> </form> </center> </body> </html>

Registration: <html> <head> <title>registration</title> </head> <body> <center> <form method="post" action="login.html"> <p><strong>name:</strong> <input type="text" name="username" size="25"> </p> <p><strong>password</strong> <input name="pass" type="password" size="6"></p> <p><strong>male</strong> <input type="radio" value="male"<hacked>&nbsp&nbsp</p> <p><strong>female</strong> <input type="radio" value="female" </p> <p><strong>address:</strong> <textarea name="address" row="6" cols="20"> </textarea> </p> <p><strong>mobile no:</strong> <input type="text" name="phno" size="10"> </p><br><br> <input type="submit" value="submit"> <input type="reset" value="reset"> </form> </center> </body> </html>

Books Catalog: <html> <head> <title>books catalog</title> </head> <body> <center><h1><p>welcome to books catalog</p></h1> <table border="1"width="25%"height="50%"> <tr> <th>computers</th> <th>electronics</th> <th>biotech</th> <th>mechanical</th> </tr> <tr> <td> </body> </html> .

.

.

.

75 %”> <frame src=”top.75%”> <frame src=”left.amazon. Validate the Registration.html” name=”left”> . The pages should resemble :www. The website should consist the following pages. Develop static pages (using only HTML) of an online Book store. user login.html” name=”top”> <frameset cols=”25%.AIM: 2.html: <frameset rows=”25%. • • • • • • • Home page Registration and user Login User profile page Books catalog Shopping cart Payment by credit cardtt Order Conformation 2. user profile and payment by credit card pages using JavaScript. PROCEDURE: Main.com.

</p></b></h2> </body> </html> Left.html: <html> <body bgcolor=”pink”> <br><br> <marquee><h1 align=”center”><b><u>ONLINE BOOK STORAGE</u></b></h1></marquee> </body> </html> Right.html” target=”right”><font color=”black”> ORDER CONFIRMATION</font></a></li><br><br> </ul> </body> </html> .html” target=”right”><font color=”black”> REGISTRATION</font></a></li><br><br> <li><a href=”profile.html” target=”right”><fontcolor=”black”> PAYMENT</font></a></li><br><br> <li><a href=”order.<frame src=”right.html” name=”right”> </frameset> </frameset> Top.html” target=”right”><font color=”black”> LOGIN</font></a></li><br><br> <li><a href=”reg. Press login if you are having id otherwise press registration.html” target=”right”><fontcolor=”black”> BOOKS CATALOG</font></a></li><br><br> <li><a href=”scart.html: <html> <body bgcolor=”pink”> <br><br><br><br><br> <h2 align=”center”> <b><p> welcome to online book storage.html” target=”right”><fontcolor=”black”> USER PROFILE</font></a></li><br><br> <li><a href=”catalog.html” target=”right”><font color=”black”> SHOPPINGCART</font></a></li><br><br> <li><a href=”payment.html: <html> <body bgcolor=”pink”> <h3> <ul> <li><a href=”login.

pwd.focus().myform. } if(flag==1) { alert(“VALID INPUT”). } } </script> <form name=”myform”> . document.myform. value==” “) { flag=0. if(document.Login.value==”“||document. } else { alert(“INVALID INPUT”).myform.id.html: <html> <body bgcolor=”pink”><br><br><br> <script language=”javascript”> function validate() { var flag=1.

phno.i<str.value==””|| document.pwd.myform.&nbsp. } var str=document.&nbsp.myform.name.1) if(!(x<=9)) { flag=0.i++) { x=str.value. break.value==””|| document.myform. for(var i=0.value==””|| document. if(document.myform.myform.&nbsp. &nbsp.length.id.addr. .substr(i.myform.value==””) { flag=0.phno.html: <html> <body bgcolor=”pink”><br><br> <script language=”javascript”> function validate() { var flag=1.value==””|| document. var x.<div align=”center”><pre> LOGIN ID:<input type=”text” name=”id”><br> PASSWORD:<input type=”password” name=”pwd”> </pre><br><br> </div> <br><br> <div align=”center”> <input type=”submit” value=”ok” onClick=”validate()”>&nbsp.<input type=”reset” value=”clear”> </form> </body> </html> Reg.

&nbsp. <input type="reset" value="clear"> </form></body></html> Catalog.&nbsp.html: <html> <body bgcolor="pink"><br><br><br> <div align="center"><pre> BOOK TITLE :<input type="text" name="title"><br> </pre><br><br> </div> <br><br> <div align="center"> <input type="submit" value="ok" name="button1">&nbsp.} } if(flag==1) { alert("VALID INPUT").&nbsp.&nbsp. } else { alert("INVALID INPUT").myform.focus(). } } </script> <form name="myform"> <div align="center"><pre> NAME :<input type="text" name="name"><br> ADDRESS :<input type="type" name="addr"><br> CONTACT NUMBER:<iput type="text" name="phno"><br> LOGINID :<input type="text" name="id"><br> PASSWORD :<input type="password" name="pwd"></pre><br><br> </div> <br><br> <div align="center"> <input type="submit" value="ok" onClick="validate()">&nbsp. document. <input type="reset" value="clear" name="button2"> </body> </html> .&nbsp.

OF BOOKS :<input type="text" name="no"><br> COST OF BOOK:<input type="text"name="cost"><br> DATE :<input tpe="text" name="date"><br></pre><br><br> </div> <br><br> <div align="center"> <input type="submit" value="ok" name="button1"> &nbsp. <input type="reset" value="clear" name="button2"> </body> </html> .html: <html> <body bgcolor="pink"><br><br><br> <div align="center"><pre> LOGIN ID :<input type="text" name="id"><br> TITLE :<input type="text" name="title"><br> NO.Order.&nbsp.&nbsp.&nbsp.

if(!(x<=9)) { flag=0.amount.substr(i. } var str=document.pwd.myform.id.myform.value==""|| document. break.html: <html> <body bgcolor="pink"><br><br><br> <script language="javascript"> function validate() { var flag=1.1).value==""|| document.i++) { x=str.myform. for(var i=0. var x.Payment.value.value=="") { flag=0. } .value==""|| document.myform.i<str.myform.amount. if(document.num.length.

document.&nbsp. } else { alert("INVALID INPUT").value.} str=document. } } </script> <form name="myform"> <div align="center"><pre> LOGIN ID :<input type="text" name="id"><br> PASSWORD :<input type="password" name="pwd"><br> AMOUNT :<input type="text" name="amount"><br> CREDITCARDNUMBER:<input type="PASSWORD" name="num+"><br></pre><br><br> </div> <br><br> <div align="center"> <input type="submit" value="ok" onClick="validate()">&nbsp. for(var i=0.i<str.lenght. if(!(x<=9)) { flag=0.substr(i.myform.focus(). <input type="reset" value="clear" > </form> </body> </html> .1).myform.num. break.&nbsp.i++) { x=str.&nbsp. } } if(flag==1) { alert("VALID INPUT").

Profile.id.myform.myform.myform.pwd. } } </script> <form name="myform"> <div align="center"><pre> .value=="") { flag=0.value==""|| document.html: <html> <body bgcolor="pink"><br><br><br> <script language="javascript"> function validate() { var flag=1. } else { alert("INVALID INPUT"). } if(flag==1) { alert("VALID INPUT").focus(). if(document. document.

&nbsp. <input type="reset" value="clear" > </form> </body> </html> .&nbsp.&nbsp.LOGIN ID :<input type="text" name="id"><br> PASSWORD:<input type="password" name="pwd"></pre><br><br> </div> <br><br> <div align="center"> <input type="submit" value="ok" onClick="validate()">&nbsp.

.

.

.

.

.

which takes user Id as an input and returns the User details by taking the user information from the XML document.zip to a directory(E:\tr) Then extract the content of above jar file using the following command E:\tr> jar XVF Xmlbeans-current-src.%Path%.3>ant As part of the Xmlbeans-1.which contains 10 users Information.3/bin we get the tool called scomp(schema compiler) . Create and save anXML document at the server.0.4\bin.0.write a Program. PROCEDURE: Step 1: Copy xmlbeans – current-src. Then give the command E:\tr\Xmlbeans-1. Step 3: Move to the directory Xmlbeans-1.zip Step 2: Search for the ant tool for complining all the extracted java files and set that to path Set Path=C:\j2sdkee1.AIM: 3.0.3 make sure that there is no folder with the name build.

%Path%.xsd in E:\xmlb directory E:\xmlb>scomp--. Step 5: Open the Xmlspy>file>new>xsdfile>ok Schema design > schema setting> Select notarget namespace Give the root element name as user then right click and select add child/sequence then right click select add child/element and give the name as user id repeat this.4\bin.T XYZ Rajahmundry A.%path% E:\Xmlb>scomp No error means Xmlbeans is loaded correctly.city State Save this as user. Create src.which takes user Id as an input and returns the User details by taking the user information from the XML document.and add the elements as Userid User— name Address --------.zip Step 2: Search for the ant tool for complining all the extracted java files and set that to path Set Path=C:\j2sdkee1.Step 4: Create the Xml directory in E:\ Then given the command E:\Xmlb>set path=E:\tr\Xmlbeans-1. Step 3: Move to the directory Xmlbeans-1. PROCEDURE: Step 1: Copy xmlbeans – current-src.0.3 make sure that there is no folder with the name . Create and save anXML document at the server.cls directories under Xmlb.P AIM: 3.0.srg –d cls user.which contains 10 users Information.write a Program.xsd Output: 1 III I.zip to a directory(E:\tr) Then extract the content of above jar file using the following command E:\tr> jar XVF Xmlbeans-current-src.3\bin.

xsd in E:\xmlb directory E:\xmlb>scomp--.and add the elements as Userid User— name Address --------.city State Save this as user. Step 5: Open the Xmlspy>file>new>xsdfile>ok Schema design > schema setting> Select notarget namespace Give the root element name as user then right click and select add child/sequence then right click select add child/element and give the name as user id repeat this.0.build.%path% E:\Xmlb>scomp No error means Xmlbeans is loaded correctly.cls directories under Xmlb.0. password. . Create src.srg –d cls user.xml. Each user should have a separate Shopping Cart.P AIM: 4.3/bin we get the tool called scomp(schema compiler) Step 4: Create the Xml directory in E:\ Then given the command E:\Xmlb>set path=E:\tr\Xmlbeans-1. credit card number) would be stored in web.3\bin. Convert the static webpages of assignments 2 into dynamic webpages using servlets and cookies.T XYZ Rajahmundry A. Install TOMCAT web server. Then give the command E:\tr\Xmlbeans-1.3>ant As part of the Xmlbeans-1. Hint: Users information (user id.0.xsd Output: 1 III I.

3//EN" "http://java.PROCEDURE: First install the tomcat into the system.jar.jar etc…) under lib subdirectories.4 Examples</display-name> <description> Servlet 2.dtd"> <web-app> <display-name>Servlet 2.com/dtd/web-app_2_3.//DTD Web Application 2. Next under WEB-INF create two subclasses lib.0" encoding="iso-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems. Then make a subdirectly(eg.E(web browser) give the url as http..bat run At the I.classes12. </description> <servlet> <servlet-name>reg</servlet-name> <servlet-class>reg</servlet-class> </servlet> <servlet> <servlet-name>login</servlet-name> <servlet-class>login</servlet-class> </servlet> . Inc.classes and web.xml <?xml version="1.//localhost:8080//tr/htmlfile or servlet url pattern Portno 8080 is assigned for the tomcat.xml Next place all the class files under the classes and jar files(servlet-api.sun. Web. tr) in the \tomcat\webapps. After this start tomcat by giving the following command at the instll_dir>tomcat>bin Catalina.4 Examples. Under tr create WEB-INF directory and also place the html files in this tr directory only.

<servlet> <servlet-name>profile</servlet-name> <servlet-class>profile</servlet-class> </servlet> <servlet> <servlet-name>catalog</servlet-name> <servlet-class>catalog</servlet-class> <servlet-mapping> <servlet-name>order</servlet-name> <url-p</servlet> <servlet> <servlet-name>order</servlet-name> <servlet-class>order</servlet-class> </servlet> attern>order</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>catalog</servlet-name> <url-pattern>catalog</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>profile</servlet-name> <url-pattern>profile</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>login</servlet-name> <url-pattern>login</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>reg</servlet-name> <url-pattern>reg</url-pattern> </servlet-mapping> </web-app> .

dtd"> <html xmlns="http://www.html <html> <body bgcolor="pink"><br /><br /><br /> <form name="myform" method="post" action="/tr/login"> <div align="center"><pre> LOGIN ID :<input type="text" name="id" /><br /> .html">LOGIN</a> <a href="/tr/reg.0 Transitional//EN" "http://www.org/TR/xhtml1/DTD/xhtml1-transitional.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.Main. Press LOGIN if you are having id otherwise press REGISTRATION </b></pre></h2> <br /><br /><pre> <div align="center"><a href="/tr/login.org/1999/xhtml"> <body bgcolor="pink"> <br /><br /><br /><br /><br /> <h1 align="center"><U>ONLINE BOOK STORAGE</U></h1><br /><br /><br /> <h2 align="center"><pre> <b>Welcome to online book storage.html"> REGISTRATION</a></div></pre> </body> </html> Login.w3.w3.

&nbsp.0 Transitional//EN" "http://www.org/1999/xhtml"> <body bgcolor="pink"><br /><br /> <form name="myform" method="post" action="/tr/reg"> <div align="center"><pre> NAME :<input type="text" name="name" /><br /> ADDRESS :<input type="text" name="addr" /><br /> CONTACT NUMBER :<input type="text" name="phno" /><br /> LOGINID :<input type="text" name="id" /><br /> PASSWORD :<input type="password" name="pwd" /></pre><br /><br /> </div> <br /><br /> <div align="center"> <input type="submit" value="ok" onclick="validate()" /> &nbsp.<input type="reset" value="clear" /> </div> </form> </body> </html> Reg.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.<input type="reset" value="clear" /> </div> </form> .dtd"> <html xmlns="http://www.&nbsp.&nbsp.&nbsp.&nbsp.w3.&nbsp.&nbsp.&nbsp.&nbsp.PASSWORD :<input type="password" name="pwd" /></pre><br /><br /> </div> <br /><br /> <div align="center"> <input type="submit" value="ok" onclick="validate()" /> &nbsp.&nbsp.org/TR/xhtml1/DTD/xhtml1-transitional.w3.

&nbsp.&nbsp.<input type="reset" value="clear" /> </div> </form> </body> </html> .html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.</body> </html> Profile.&nbsp.&nbsp.&nbsp.w3.org/TR/xhtml1/DTD/xhtml1-transitional.w3.dtd"> <html xmlns="http://www.0 Transitional//EN" "http://www.org/1999/xhtml"> <body bgcolor="pink"><br /><br /><br /> <form name="myform" method="post" action="/tr/profile"> <div align="center"><pre> LOGIN ID :<input type="text" name="id" /><br /> </pre><br /><br /> </div> <br /><br /> <div align="center"> <input type="submit" value="ok" onclick="validate()" /> &nbsp.

dtd"> <html xmlns="http://www.Catalog.html .html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.w3. <input type="reset" value="clear" name="button2"/> </div> </form> </body> </html> Order.0 Transitional//EN" "http://www.&nbsp.&nbsp.&nbsp.&nbsp.org/1999/xhtml"> <body bgcolor="pink"><br /><br /><br /> <form method="post" action="/tr/catalog"> <div align="center"><pre> BOOK TITLE :<input type="text" name="title" /><br /> </pre><br /><br /> </div> <br /><br /> <div align="center"> <input type="submit" value="ok" name="button1"/>&nbsp.org/TR/xhtml1/DTD/xhtml1-transitional.&nbsp.w3.

&nbsp.<input type="reset" value="clear" name="button2"/> </div> </form> </body> </html> Login.0 Transitional//EN" "http://www.&nbsp.&nbsp.org/TR/xhtml1/DTD/xhtml1-transitional.org/1999/xhtml"> <body bgcolor="pink"><br /><br /> <form method="post" action="/tr/reg"> <div align="center"><pre> NAME :<input type="text" name="name" /><br /> PASSWORD :<input type="password" name="pwd" /> TITLE :<input type="text" name="title" /><br /> NO.dtd"> <html xmlns="http://www.java .<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1. OF BOOKS :<input type="text" name="no" /><br /> DATE :<input type="text" name="date" /><br /> CREDIT CARD NUMBER:<input type="password" name="cno" /><br /></pre><br /><br /> </div> <br /><br /> <div align="center"> <input type="submit" value="ok" name="button1"/> &nbsp.&nbsp.&nbsp.w3.w3.

import java.sql.*; import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class login extends HttpServlet { public void service(HttpServletRequest req,HttpServletResponse resp) throws ServletException,IOException { PrintWriter pw=resp.getWriter(); pw.println("<html><body bgcolor=\"pink\"); String id=req.getParamenter("id"); String pwd=req.getParameter("pwd"); try { Driver d=new oracle.jdbc.driver.OracleDriver(); DriverManager.registerDriver(d); Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1 521:orcl","scott","tiger"); Statement stmt=con.createStatement(); String sqlstmt="select id,password from login"; ResultSet rs=stmt.executeQuery(sqlstmt); int flag=0; while(rs.next()) { if(id.equal(rs.getString(1))&&pwd.equals(rs.getString(2))) { flag=1; } } if(flag==0) { pw.println("SORRY INVALID ID TRY AGAIN ID<br><br>"); pw.println("<a href=\"/tr/login.html\">press LOGIN to RETRY</a>"); } else { pw.println("VALID LOGIN ID<br><br>"); pw.println("<h3><ul>"); pw.println("<li><ahref=\"profile.html\"><fontcolor=\"blac k\">USER PROFILE</font> </a></li><br><br>");

pw.println("<li><ahref=\"catalog.html\"><fontcolor=\"black\">BO OKS CATALOG</font></a></li><br><br>"); pw.println("<li><ahref=\"order.html\"><fontcolor=\"black\">ORD ER CONFIRMATION</font> </a></li><br><br>"); } pw.println("</body></html>"); } catch(Exception e) { resp.sendError(500,e.toString()); } } }

Reg.html import java.sql.*; import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class login extends HttpServlet { public void service(HttpServletRequest req,HttpServletResponse resp) throws ServletException,IOException { PrintWriter pw=resp.getWriter(); pw.println("<html><body bgcolor=\"pink\"); String name=req.getParamenter("name"); String addr=req.getParameter("addr"); String phno=req.getParameter("phno"); String id=req.getParamenter("id"); String pwd=req.getParameter("pwd");

int no=Integer.parseInt(phno); try { Driver d=new oracle.jdbc.driver.OracleDriver(); DriverManager.registerDriver(d); Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1 521:orcl","scott","tiger"); Statement stmt=con.createStatement(); String sqlstmt="select id,password from login"; ResultSet rs=stmt.executeQuery(sqlstmt); int flag=0; while(rs.next()) { if(id.equal(rs.getString(1))&&pwd.equals(rs.getString(2))) { flag=1; } } if(flag==1) { pw.println("SORRY INVALID ID ALREADY EXITS TRY AGAIN WITH NEW ID<br><br>"); pw.println("<a href=\"/tr/reg.html\">press REGISTER to RETRY</a>"); } else { Statement stmt1=con.createStatement(); stmt1.executeUpdate("insertintologin values("+names","+addr+","+no+","+id+","+pwd+")"); pw.println("YOUR DETAILS ARE ENTERED<br><br>"); pw.println("<a href=\"/tr/login.html\">press LOGIN to login</a>"); } pw.println("</body></html>"); } catch(Exception e) { resp.sendError(500,e.toString()); } } }

Catlog.java import java.sql.*; import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class login extends HttpServlet { public void service(HttpServletRequest req,HttpServletResponse resp) throws ServletException,IOException { PrintWriter pw=resp.getWriter(); pw.println("<html><body bgcolor=\"pink\"); String title=req.getParameter("title"); try { Driver d=new oracle.jdbc.driver.OracleDriver(); DriverManager.registerDriver(d); Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1 521:orcl","scott","tiger"); Statement stmt=con.createStatement(); String sqlstmt="select id,password from login"; ResultSet rs=stmt.executeQuery(sqlstmt); int flag=0; while(rs.next()) { pw.println(",div align=\"center\">"); pw.println("TITLE :"+rs.getString(1)+"<br>"); pw.println("AUTHOR :"+rs.getString(2)+"<br>"); pw.println("VERSION :"+rs.getString(3)+"<br>"); pw.println("PUBLISHER :"+rs.getString(4)+"<br>"); pw.println("COST :"+rs.getString(5)+"<br>");

pw.println("</div"); flag=1; } if(flag==0) { pw.println("SORRY INVALID TITLE TRY AGAIN <br><br>"); pw.println("<a href=\"/tr/catalog.html\">press HERE to RETRY</a>"); } pw.println("</body></html>"); } catch(Exception e) { resp.sendError(500,e.toString()); } } }

Profile.java import java.sql.*; import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class login extends HttpServlet

ResultSet rs=stmt.driver. pw. } if(flag==0) { pw.registerDriver(d).println("PHONE NO :"+rs.toString()). pw. } pw.html\">press HERE to RETRY</a>"). Statement stmt=con.println("<html><body bgcolor=\"pink\").println("<div align=\"center\">").e.OracleDriver().println("<a href=\"/tr/profile. } catch(Exception e) { resp.getString(3)+"<br>").println("ADDRESS :"+rs. String id=req.getString(1)+"<br>").println("SORRY INVALID ID TRY AGAIN ID<br><br>").executeQuery(sqlstmt). pw. Connection con=DriverManager.println("</body></html>").println("</div>").println("NAME :"+rs. DriverManager.jdbc.createStatement(). try { Driver d=new oracle. flag=1. while(rs."tiger"). pw."scott".sendError(500.IOException { PrintWriter pw=resp. pw. } } } .println("<br><br><br>"). pw. pw. int flag=0.getString(2)+"<br>").getParamenter("id").{ public void service(HttpServletRequest req. String sqlstmt="select * from login where id="+id+"".HttpServletResponse resp) throws ServletException.getConnection("jdbc:oracle:thin: @localhost:1521:orcl".getWriter().next()) { pw.

String id=req. String cno=req.driver. import java. String title=req. public class login extends HttpServlet { public void service(HttpServletRequest req.*.getParameter("title").*.sql.registerDriver(d). import javax. String pwd=req.getParameter("pwd").util.parseInt(count1).OracleDriver().*. Connection con=DriverManager.servlet. import java.getParameter("date").jdbc.getParameter("no"). import javax.IOException { PrintWriter pw=resp.getWriter().io.http. DriverManager. try { Driver d=new oracle.HttpServletResponse resp) throws ServletException.servlet. String date=req.*. .Order."tiger").getParamenter("id").getParameter("cno").println("<html><body bgcolor=\"pink\").java import java.*.getConnection("jdbc:oracle:thin:@localhost:1 521:orcl". int count=Integer. pw."scott". String count1=req.

println("</body></html>").executeQuery(sqlstmt).parseInt(rs1.next()) { flag1=1. ResultSet rs1=stmt2. stmt1. . pw. } if(flag1==0) { pw.next()) { if(id.html\\">press HERE to RETRY</a>").executeUpdate("insertintodetails values('"+id+". Statement stmt1=con.println("SORRY INVALID ID TRY AGAIN ID<br><br>").'"+title+"'+amount+'".equals(rs.getString(2))) { flag=1. pw. con.println("<a href=\\"/tr/order.createStatement().getString(1)). } } if(flag==0) { pw. x=Integer. String sqlstmt="select id. pw. String s="select cost from book where title="+title+"".createStatement(). while(rs. } else { Statement stmt2=con.close().println("<a href=\\"/tr/order.executeQuery(s)."'+cno+'")"').x.Statement stmt=con.html\\">press HERE to RETRY</a>"). int flag1=0. ResultSet rs=stmt. while(rs1. } } pw.equals(rs. amount=count*x. int flag=0. pw.println("AMOUNT :"+amount+"<br><br><br><br>").getString(1))&&pwd.println("SORRY INVALID ID TRY AGAIN ID<br><br>").println("YOUR ORDER has taken<br>").amount.createStatement().password from login".

} } .e.sendError(500.} catch(Exception e) { resp.toString()).

.

.

.

g. Create a database with user information and books information and books information.bat run At install-dir/bin 5) at I. The books catalogue should be dynamically loaded from the database.E give url as http://localhost:8081/tr1/main.html . PROCEDURE: 1) 2) 3) 4) Create your own directory under tomcat/webapps (e.AIM: 5. Redo the previous task using JSP by converting the static web pages of assignments 2 into dynamic web pages. tr1) Copy the html files in tr1 Copy the jsp files also into tr1 Start tomcat give the following command Catalina. Follow the MVC architecture while doing the website.

html”>LOGIN</a> href=”/tr/login.html: <html> <body bgcolor=”pink”> <br><br><br><br><br><br> <h1 align=”center”>>U>ONLINE BOOK STORAGE</u></h1><br><br><br> <h2 align=”center”><PRE> <b> Welcome to online book storage.html”>REGISTRATION</a></div></pre> </body></html> . Press LOGIN if you are having id Otherwise press REGISTRATION </b></PRE></h2> <br><br><pre> <div align=”center”><a href=”/tr/login.Main.

&nbsp.Login.html: <html> <body bgcolor=”pink”><br><br><br> <form name="myform" method="post" action=/tr1/login.&nbsp.<input type="reset" value="clear"> </form> </body> </html> .&nbsp.&nbsp.jsp"> <div align="center"><pre> LOGIN ID : <input type="passwors" name="pwd"></pre><br><br> PASSWORD : <input type="password" name="pwd"></pre><br><br> </div> <br><br> <div align="center"> <inputtype="submit"value="ok" onClick="validate()">&nbsp.

jsp"> <div align="center"><pre> NAME :<input type="text" name="name"><br> ADDRESS :<input type="text" name="addr"><br> CONTACT NUMBER : <input type="text" name="phno"><br> LOGIN ID : <input type="text" name="id"><br> PASSWORD : <input type="password" name="pwd"></pre><br><br> </div> <br><br> <div align="center"> <inputtype="submit"value="ok" onClick="validate()">()">&nbsp.&nbsp.Reg.&nbsp.&nbsp.&nbsp.html: <html> <body bgcolor="pink"><br><br> <form name="myform" method="post" action="/tr1/reg.<input type="reset" value="clear"> </form> </body> </html> .

&nbsp.&nbsp.<input type="reset" value="clear"> </form> </body> </html> .&nbsp.Profile.html: <html> <body bgcolor="pink"><br><br> <form name="myform" method="post" action="/tr1/profile.&nbsp.jsp"> <div align="center"><pre> LOGIN ID : <input type="text" name="id"><br> </pre><br><br> </div> <br><br> <div align="center"> <inputtype="submit"value="ok" onClick="validate()">()">&nbsp.

&nbsp.Catalog.&nbsp.jsp"> <div align="center"><pre> BOOK TITLE : <input type="text" name="title"><br> </pre><br><br> </div> <br><br> <div align="center"> <inputtype="submit"value="ok" name=”button1”>&nbsp.&nbsp.<inputtype="reset"value="clear" name=”button2”> </form> </body> </html> .&nbsp.html: <html> <body bgcolor="pink"><br><br><br> <form method="post" action="/tr1/catalog.

Order.<input type="reset" value="clear" name=”button2”> </form> </body> </html> .&nbsp.html: <html> <body bgcolor="pink"><br><br><br> <form method="post" action="/tr1/order.jsp"> <div align="center"><pre> LOGIN ID :<input type="text" name="id"><br> PASSWORD : <input type="password" name="pwd"><br> TITLE :<input type="text" name="title"><br> NO.&nbsp.&nbsp.&nbsp. OF BOOKS : <input type="text" name="no"><br> DATE : <input type="text" name="date"><br> CREDIT CARD NUMBER : <input type="password" name="cno"><br></pre><br><br> </div> <br><br> <div align="center"> <input type="submit" value="ok" name=”button1”>&nbsp.

OracleDriver(). } else { .registerDriver(d).io. } if(flag==0) { out. while(rs. String pwd=request.*”% %@page import=”java.”scott”.println(“<html><body bgcolor=\”pink\”>”). ResultSet rs=stmt.sql.password from login where id=”+id+” and password=”+pwd+””. out.getConnection(“jdbc:oracle:thin:@localhost:1521:orcl”.createStatement(). String sqlstmt=”select id.println(“SORRY INVALID ID TRY AGAIN ID<br><br>”).next()) { flag=1.jdbc.*”% <% out.html\”>press LOGIN to RETRY</a>”).println(“ <a href=\”/tr1/login.getParameter(“id”). int flag=0. Statement stmt=con. Driver d=new oracle.getParameter(“pwd”).driver. DriverManager. String id=request. Connection con=DriverManager.”tiger”).jsp: %@page import=”java.Login.executeQuery(sqlstmt).

%> Reg.println(“<li><ahref=\”profile.io.println(“</ul>”). int no=Integer.getParameter(“phno”).getString(1))) { flag=1. Statement stmt=con.”scott”.getParameter(“addr”). out. } out. Connection con= DriverManager.html\”><fontcolor=\”black\”>USER PROFILE</font></a></li><br><br>”).jsp: %@page import=”java.driver.html\”><fontcolor=\”black\”>ORDER CONFIRMATION</font></a></li><br><br>”).sql.out. } } if(flag==1) . Driver d=new oracle. int flag=0.println(“<html><body bgcolor=\”pink\”>”). String name=request. String sqlstmt=”select id from login”. out.html\”><fontcolor=\”black\”>BOOKS CATALOG</font></a></li><br><br>”).parseInt(phno).getParameter(“pwd”). String addr=request.println(“<li><ahref=\”catalog.equals(rs.*”% <% out.next()) { if(id. ResultSet rs=stmt.executeQuery(sqlstmt). String pwd=request. String id=request.createStatement(). DriverManager. out.getParameter(“name”).getConnection (“jdbc:oracle:thin:@localhost:1521:orcl”.println(“VALID LOGIN ID<br><br>”). String phno=request.jdbc.getParameter(“id”).registerDriver(d). out.println(“<li><ahref=\”order.”tiger”). out. while(rs.println(“<body></html>”).*”% %@page import=”java.OracleDriver().println(“<h3><ul>”).

println (“<div align=\”center\”>”).jdbc.println (“<a href =\”/tr1/login.println (“ADDRESS :”+rs.regiserDriver(d).”+no+”. Connection con= DriverManager.println(“SORRY LOGIN ID ALREADY EXISTS TRY AGAIN WITH NEW ID <br><br>”). ResultSet rs=stmt.println(“<a href=\”/tr1/profile. int flag=0.html\”>press REGISTER to RETRY</a>”).createStatement ().createStatement (). out. . %> Profile.io. Statement stmt=con. stmt1.getConnection (“jdbc:oracle:thin:@localhost:1521:orcl”. } out. out.getParameter(“id”).executeQuery (sqlstmt).”tiger”).getString(2)+”<br>”).println(“SORRY INVALID ID TRY AGAIN ID <br><br>”).”+id+”.getString(1)+”<br>”). out.println (“</div>”).println (“</body></html>”). Driver d=new oracle.*”%> <%@page import=”java.OracleDriver().println (“YOU DETAILS ARE ENTERED <br><br>”).”+pwd+”)”). out. String sqlstmt=”select * from login where id=”+id+””.html\”>press LOGIN to login</a>”).next()) { out. out. out.html\”>press HERE to RETRY </a>”).{ out. flag=1.println (“PHONE NO :”+rs. while(rs. } if(flag==0) { out.jsp: <%@page import=”java. String id=request.*”%> <% out. } else { Statement stmt1=con. DriverManager. out.”scott”.driver.println (“<html><body bgcolor=\”pink\”>”). out.executeUpdate (“insert into login values (“+name+”.println (“NAME :”+rs.getString(3)+”<br>”).sql.”+addr+”.println(“<a href=\”/tr1/reg.

regiserDriver (d).} out.getString(4)+”<br>”).getString(3)+”<br>”).getParameter (“title”).*”%> <% out.getConnection (“jdbc:oracle:thin:@localhost:1521:orcl”. flag=1.println (“<div align=\”center\”>”).println (“</div>”).println (“<html><body bgcolor=\”pink\”>”).driver. ResultSet rs=stmt. Statement stmt=con.createStatement ().getString(1)+”<br>”). out. Connection con= DriverManager. } if(flag==0) { . out.next()) { out.getString(2)+”<br>”).jdbc. String title=request.sql.”tiger”).jsp: <%@page import=”java.*”%> <%@page import=”java.io.OracleDriver (). out.println (“</body></html>”). out.println (“COST :” +rs. String sqlstmt=”select * from book where title=”+title+””.”scott”. DriverManager. Driver d=new oracle.getString(5)+”<br>”).println (“TITLE :”+rs. out. int flag=0. %> Catalog. out. while(rs.println (“VERSION:”+rs.executeQuery (sqlstmt).println (“PUBLISHER :” +rs.println (“AUTHOR :”+rs.

Driver d=new oracle. int count=Integer.jsp: <%@page import=”java.”scott”.createStatement ().println(“SORRY INVALID ID TRY AGAIN ID <br><br>”). out.equals(rs. String id=request.getParameter (“date”). int flag=0. password from login”. String cno=request.*”%> <% out. String pwd=request.getParameter (“title”).x. } out.”tiger”).println(“<a href=\”/tr1/catalog.driver. Statement stmt=con. ResultSet rs=stmt.getParameter (“id”).next()) { if(id.*”%> <%@page import=”java.getParameter (“no”). String sqlstmt=”select id.getConnection (“jdbc:oracle:thin:@localhost:1521:orcl”. %> Order.parseInt(count1).println (“</body></html>”). Connection con= DriverManager.getString(2))) { flag=1.io. while(rs. String date=request. } } .println (“<html><body bgcolor=\”pink\”>”).regiserDriver (d). DriverManager.OracleDriver ().jdbc.executeQuery (sqlstmt).equals(rs.amount.out.getParameter (“cno”).html\”>press HERE to RETRY </a>”).getParameter (“pwd”).getString(1))&& pwd. String title=request.sql. String count1=request.

createStatement(). } } out.”+amount+”.%> . int flag1=0.println(“SORRY INVALID ID TRY AGAIN ID <br><br>”).println(“SORRY INVALID BOOK TRY AGAIN <br><br>”).getString(1)). x=Integer.parseInt(rs1.println(“<a href=\”/tr1/order. } else { Statement stmt2=con.html\”>press HERE to RETRY </a>”). out.println (“YOU ORDER HAS TAKEN<br>”). String s=”select cost from book where title=”+title+””.”+date+”. ResultSet rs1=stmt2. out.println(“<a href=\”/tr1/order.executeQuery(s).next()) { flag1=1. amount=count*x. stmt1. out. out.createStatement (). while(rs1. Statement stmt1=con.println (“</body></html>”).println(“AMOUNT :”+amount+”<br><br><br><br>”).executeUpdate (“insert into details (“+id+”.”+cno+”)”).if(flag==0) { out.html\”>press HERE to RETRY </a>”). } if(flag1==0) { out.”+title+”.

.

.

.

.

war .war file At that directory path in cmd give the command as Jar xvf struts-blank.AIM: 6.Implement the "Hello World!" program using JSP Struts Framework PROCEDURE: Step 1: in tomcat install directory Open tomcat/webapps Create a subdirectory(ts) Copy the struts-blank.

*.io.java: import java.class file to webapps/ts/WEB-INF/classes ActionOne. pw.servelet-appi.*.println("HELLO WORLD!").jar.struts.jar.jar. public class ActionOne extends Action { publicActionForwardexecute(ActionMappingmapping.servlet.HttpServletRequest request.apache.*.jar into work d directory.println("---Action executed----").servlet. import org.*. return null. PrintWriter pw=response. then copy the ActionOne. } } .servlet-api.ActionFormform. import javax.HttpServletResponse response)throws Exception { System. import javax.Step 2: create a directory (work in e:\) and copy struts.Then set the classpath as set classpath=struts.getWriter().action.http.out.

xml file <?xml version="1.Step 3: Struts-Config.0" encoding="UTF-8"?> <struts-config> <action-mappings> <action path="/xxx" type="ActionOne"/> </action-mappings> </struts-config> .

do</url-pattern> </servlet-mapping> .struts.0" encoding="ISO-8859-1"?> <web-app> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.action.Step 4: Web.ActionServlet</servlet-class> <init--param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml <?xml version="1.xml</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>2</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> <!--Standard Action Servlet Mapping --> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.

do AIM: 1. Develop static pages (using Only HTML) of an online Book store.E give the url as http:localhost:8080/ts/xxx.The pages should resemble:www.tld</taglib-location> </taglib> <taglib> <taglib-uri>/tags/struts-logic</taglib-uri> <taglib-location>/WEB-INF/struts-logic.Struts Tag Library Descriptors --> <taglib> <taglib-uri>/tags/struts-bean</taglib-uri> <taglib-location>/WEB-INF/struts-html.The website should consists the following pages.jsp</welcome-file> </welcome-file-list> <!-. • • • • Home page Registration User Login Books catalog PROCEDURE: Main page: <html> <head> .tld</taglib-location> </taglib> <taglib> <taglib-uri>/tags/struts-nested</taglib-uri> <taglib-location>/WEB-INF/struts-nested.amazon.<!-.The Usual Welcome File List --> <welcome-file-list> <welcome-file>index.tld</taglib-location> </taglib> <taglib> <taglib-uri>/tags/struts-tiles</taglib-uri> <taglib-location>/WEB-INF/struts-tiles.com.tld</taglib-location> </taglib> </web-app> Step 5: then in I.

html"> <input type="submit"value="click">registration user login hear </center> </body> </html> Login page: <html> <head> <title>login page</title> </head> <body> <center> <form method="post" action="login.</p> <input type="submit" value="submit">&nbsp&nbps .html"> <p><strong>name:</strong> <input type="text" name="username" size="25"> </p> <p><strong>password</strong> <input name="pass" type="password" size="6"></p> <p><strong>male</strong> <input type="radio" value="male"<hacked>&nbsp&nbsp</p> <p><strong>female</strong> <option><input type="radio" value="female"<hacked>&nbsp.<title>home page</title> </head> <body> <center><b><h1>welcome to amazon.com</h1></b><br><br> <form method="post"action="login.

html">new users register hear </a> </form> </center> </body> </html> Registration: <html> <head> <title>registration</title> </head> <body> <center> <form method="post" action="login.<input type="reset" value="reset"> <a href="registration.html"> <p><strong>name:</strong> <input type="text" name="username" size="25"> </p> <p><strong>password</strong> <input name="pass" type="password" size="6"></p> <p><strong>male</strong> <input type="radio" value="male"<hacked>&nbsp&nbsp</p> <p><strong>female</strong> <input type="radio" value="female" </p> <p><strong>address:</strong> .

<textarea name="address" row="6" cols="20"> </textarea> </p> <p><strong>mobile no:</strong> <input type="text" name="phno" size="10"> </p><br><br> <input type="submit" value="submit"> <input type="reset" value="reset"> </form> </center> </body> </html> Books Catalog: <html> <head> <title>books catalog</title> </head> <body> <center><h1><p>welcome to books catalog</p></h1> <table border="1"width="25%"height="50%"> <tr> <th>computers</th> <th>electronics</th> <th>biotech</th> <th>mechanical</th> </tr> <tr> <td> </body> </html> .

.

.

.

.

Validate the Registration.AIM: 2. user profile and payment by credit card pages using JavaScript. user login. The website should consist the following pages.com. Develop static pages (using only HTML) of an online Book store. • • • • • • • Home page Registration and user Login User profile page Books catalog Shopping cart Payment by credit cardtt Order Conformation 2. 75 %”> .amazon. PROCEDURE: Main.html: <frameset rows=”25%. The pages should resemble :www.

html” name=”right”> </frameset> </frameset> Top.html” name=”left”> <frame src=”right.html” target=”right”><fontcolor=”black”> PAYMENT</font></a></li><br><br> <li><a href=”order.html” target=”right”><font color=”black”> ORDER CONFIRMATION</font></a></li><br><br> .html: <html> <body bgcolor=”pink”> <h3> <ul> <li><a href=”login. </p></b></h2> </body> </html> Left.html: <html> <body bgcolor=”pink”> <br><br> <marquee><h1 align=”center”><b><u>ONLINE BOOK STORAGE</u></b></h1></marquee> </body> </html> Right.<frame src=”top.html” target=”right”><fontcolor=”black”> BOOKS CATALOG</font></a></li><br><br> <li><a href=”scart.html” target=”right”><font color=”black”> SHOPPINGCART</font></a></li><br><br> <li><a href=”payment.html” target=”right”><font color=”black”> LOGIN</font></a></li><br><br> <li><a href=”reg.html: <html> <body bgcolor=”pink”> <br><br><br><br><br> <h2 align=”center”> <b><p> welcome to online book storage.html” target=”right”><fontcolor=”black”> USER PROFILE</font></a></li><br><br> <li><a href=”catalog.75%”> <frame src=”left.html” target=”right”><font color=”black”> REGISTRATION</font></a></li><br><br> <li><a href=”profile.html” name=”top”> <frameset cols=”25%. Press login if you are having id otherwise press registration.

value==”“||document.myform. value==” “) { flag=0. if(document.</ul> </body> </html> login. } if(flag==1) { alert(“VALID INPUT”).html: <html> <body bgcolor=”pink”><br><br><br> <script language=”javascript”> function validate() { var flag=1.myform. document. } .myform.focus().pwd.id. } else { alert(“INVALID INPUT”).

value==””|| document.myform.pwd.&nbsp.myform.value==””) { flag=0. } var str=document. &nbsp.html: <html> <body bgcolor=”pink”><br><br> <script language=”javascript”> function validate() { var flag=1.value==””|| document.} </script> <form name=”myform”> <div align=”center”><pre> LOGIN ID:<input type=”text” name=”id”><br> PASSWORD:<input type=”password” name=”pwd”> </pre><br><br> </div> <br><br> <div align=”center”> <input type=”submit” value=”ok” onClick=”validate()”>&nbsp.&nbsp.value==””|| document. for(var i=0.&nbsp.name. if(document.i<str.value.phno.myform.phno.1) if(!(x<=9)) .myform. var x.i++) { x=str.length.substr(i.myform.<input type=”reset” value=”clear”> </form> </body> </html> reg.id.addr.myform.value==””|| document.

} } </script> <form name="myform"> <div align="center"><pre> NAME :<input type="text" name="name"><br> ADDRESS :<input type="type" name="addr"><br> CONTACT NUMBER:<iput type="text" name="phno"><br> LOGINID :<input type="text" name="id"><br> PASSWORD :<input type="password" name="pwd"></pre><br><br> </div> <br><br> <div align="center"> <input type="submit" value="ok" onClick="validate()">&nbsp.&nbsp.&nbsp. <input type="reset" value="clear"> </form></body></html> catalog.focus(). <input type="reset" value="clear" name="button2"> </body> </html> .&nbsp.html: <html> <body bgcolor="pink"><br><br><br> <div align="center"><pre> BOOK TITLE :<input type="text" name="title"><br> </pre><br><br> </div> <br><br> <div align="center"> <input type="submit" value="ok" name="button1">&nbsp.{ flag=0.&nbsp. break. } else { alert("INVALID INPUT").&nbsp.myform. document. } } if(flag==1) { alert("VALID INPUT").

OF BOOKS :<input type="text" name="no"><br> COST OF BOOK:<input type="text"name="cost"><br> DATE :<input tpe="text" name="date"><br></pre><br><br> </div> <br><br> <div align="center"> <input type="submit" value="ok" name="button1"> &nbsp.&nbsp.html: <html> <body bgcolor="pink"><br><br><br> <div align="center"><pre> LOGIN ID :<input type="text" name="id"><br> TITLE :<input type="text" name="title"><br> NO.&nbsp.&nbsp.order. <input type="reset" value="clear" name="button2"> </body> </html> .

i++) { x=str.myform.length.value==""|| document. var x.id.myform.html: <html> <body bgcolor="pink"><br><br><br> <script language="javascript"> function validate() { var flag=1.value.substr(i.value==""|| document.payment.num. } var str=document.myform. if(document.amount. for(var i=0.value=="") { flag=0. if(!(x<=9)) .i<str.pwd.value==""|| document.1).myform.myform.amount.

num.lenght.myform.myform. break. } } if(flag==1) { alert("VALID INPUT").i++) { x=str.substr(i. } } </script> <form name="myform"> <div align="center"><pre> LOGIN ID :<input type="text" name="id"><br> PASSWORD :<input type="password" name="pwd"><br> AMOUNT :<input type="text" name="amount"><br> CREDITCARDNUMBER:<input type="PASSWORD" name="num+"><br></pre><br><br> </div> <br><br> <div align="center"> <input type="submit" value="ok" onClick="validate()">&nbsp. <input type="reset" value="clear" > </form> </body> </html> . } } str=document. for(var i=0. } else { alert("INVALID INPUT"). if(!(x<=9)) { flag=0.&nbsp.&nbsp.value. break.{ flag=0.focus().i<str.&nbsp. document.1).

html: <html> <body bgcolor="pink"><br><br><br> <script language="javascript"> function validate() { var flag=1. .focus(). document.myform.myform.profile. } else { alert("INVALID INPUT").value=="") { flag=0. if(document.myform. } if(flag==1) { alert("VALID INPUT").pwd.id.value==""|| document.

&nbsp.} } </script> <form name="myform"> <div align="center"><pre> LOGIN ID :<input type="text" name="id"><br> PASSWORD:<input type="password" name="pwd"></pre><br><br> </div> <br><br> <div align="center"> <input type="submit" value="ok" onClick="validate()">&nbsp.&nbsp. <input type="reset" value="clear" > </form> </body> </html> .&nbsp.

Sign up to vote on this title
UsefulNot useful