Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

Stanley College of Engineering & Technology for Women

Chapel Road, Hyderabad

Roll No:

1 6 0 6 1 0 7 3 3 1 1 2 Exp No: ____ _

Date:

___________

Page No: ____________________

Faculty: ___________

7. CREATION OF DYNAMIC CONTENT IN WEB APPLICATION USING JSP.


HOMEPAGE:--- (task_jsp.html)
<html> <head> <title>Student Percentage Calculator</title> </head> <body> <center> <h2>Welcome to III Yr I-sem Percentage Calculator</h2> <form method="POST" action="http://localhost:9090/jsp_task/beans.jsp"> <table> <tr> <td> UserName </td > <td> <input type="text" name="username"/> </td> </tr> <tr> <td> Password </td > <td> <input type="password" name="password"/> </td> </tr> <p>Enter Marks</p><br/> <tr> <td>DAA</td> <td><input type="text" name="mark1"/></td> </tr> <tr> <td>DBMS</td> <td><input type="text" name="mark2"/></td> </tr> </table> <input type="submit" name="submit" value="calculate"/> </form> </center> </body> </html>

Stanley College of Engineering & Technology for Women


Chapel Road, Hyderabad

Roll No:

1 6 0 6 1 0 7 3 3 1 1 2 Exp No: ____ _

Date:

___________

Page No: ____________________

Faculty: ___________

Beans.jsp:<%@ page import="user.MarksBean" %> <jsp:useBean id="marksbean" scope="page" class="user.MarksBean"> <jsp:setProperty name="marksbean" property="username" value='<%=request.getParameter("username") %>'/> <jsp:setProperty name="marksbean" property="mark1"/> <jsp:setProperty name="marksbean" property="mark2"/> </jsp:useBean> <html> <head> <title>Percentage</title> </head> <body> <p>Welcome: <jsp:getProperty name="marksbean" property="username"/> </p> <p>Your marks are :<br/> DAA:<jsp:getProperty name="marksbean" property="mark1"/><br/> DBMS:<jsp:getProperty name="marksbean" property="mark2"/> </p><br/> <p>Your Percentage is <%= marksbean.getCalculateper() %> </p><br /> <p>Comments on your percentage is <%= marksbean.getComments() %> </p> </body> </html>

Stanley College of Engineering & Technology for Women


Chapel Road, Hyderabad

Roll No:

1 6 0 6 1 0 7 3 3 1 1 2 Exp No: ____ _

Date:

___________

Page No: ____________________

Faculty: ___________

Web.xml
<?xml version="1.0" encoding="ISO-8859-1"?> <!--<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> --> <web-app> </web-app>

Stanley College of Engineering & Technology for Women


Chapel Road, Hyderabad

Roll No:

1 6 0 6 1 0 7 3 3 1 1 2 Exp No: ____ _

Date:

___________

Page No: ____________________

Faculty: ___________

MarksBean.java:package user; import java.io.*; public class MarksBean { String username=""; String mark1="",mark2=""; int tot; public MarksBean() { } public void setUsername(String userName) { this.username=userName; } public String getUsername() { return this.username; } public void setMark1(String mark1) { this.mark1=mark1; } public String getMark1() { return mark1; } public void setMark2(String mark2) { this.mark2=mark2; } public String getMark2() { return mark2; } public int getCalculateper()throws IOException { tot=((Integer.parseInt(mark1))+(Integer.parseInt(mark2)))/2;

Stanley College of Engineering & Technology for Women


Chapel Road, Hyderabad

Roll No:

1 6 0 6 1 0 7 3 3 1 1 2 Exp No: ____ _

Date:

___________

Page No: ____________________

Faculty: ___________

return tot; } public String getComments() { if(tot>=75) return "You passed with distinction"; else if(tot>=60 && tot<75) return "You passed in first class"; else return " You passed in second class"; } }

Stanley College of Engineering & Technology for Women


Chapel Road, Hyderabad

Roll No:

1 6 0 6 1 0 7 3 3 1 1 2 Exp No: ____ _

Date:

___________

Page No: ____________________

Faculty: ___________

8.CREATION OF DYNAMIC CONTENT IN WEB APPLICATION USING ASP.NET


Project Name:- reddy File Name:- myp
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>Details</title> </head> <center> <h1>Enter Marks Details</h1> </center> <body> <form id="form1" runat="server"> <center> <div> <br /><br /><br /> <asp:Label ID="Label1" runat="server" Text="Name"></asp:Label> <asp:TextBox ID="Name" runat="server"></asp:TextBox> <br /> <asp:Label ID="Label2" runat="server" Text="DBMS"></asp:Label> <asp:TextBox ID="DBMS" runat="server"></asp:TextBox> <br /> <asp:Label ID="Label3" runat="server" Text="DAA"></asp:Label> <asp:TextBox ID="DAA" runat="server"></asp:TextBox> <br /><br /> <asp:Button ID="Submit" runat="server" Text="Submit" /> <br /><br /> </div> </center> </form>

Stanley College of Engineering & Technology for Women


Chapel Road, Hyderabad

Roll No:

1 6 0 6 1 0 7 3 3 1 1 2 Exp No: ____ _

Date:

___________

Page No: ____________________

Faculty: ___________

<center> <% if(IsPostBack) { Response.Write("Welcome " +Name.Text+ " !!!\n"); var total = System.Convert.ToInt32(DBMS.Text) + System.Convert.ToInt32(DAA.Text); Response.Write("Your Total is " + total); } %> </center> </body> </html>

Stanley College of Engineering & Technology for Women


Chapel Road, Hyderabad

Roll No:

1 6 0 6 1 0 7 3 3 1 1 2 Exp No: ____ _

Date:

___________

Page No: ____________________

Faculty: ___________

9.PROVIDING DATA STORE SUPPORT FOR WEB SITE USING JDBC. Login.html:<html> <head> <title>Login</title> </head> <h1> <center>Enter Details</center> </h1> <body> <form action="http://localhost:9090/JDBC/insertdata.jsp"> <center> <table> <tr> <td>Name</td> <td><input type="text" name="name"></td> </tr> <tr> <td>Address</td> <td><input type="text" name="address"></td> </tr> </table> </center> <br/> <center> <input type="submit" name="submit" value="Submit"/> </form> </center> </body> </html>

Stanley College of Engineering & Technology for Women


Chapel Road, Hyderabad

Roll No:

1 6 0 6 1 0 7 3 3 1 1 2 Exp No: ____ _

Date:

___________

Page No: ____________________

Faculty: ___________

insertdata.jsp:<%@page import="java.sql.*"%> <% String name=request.getParameter("name"); String address=request.getParameter("address"); try { Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","sriya"); Statement st=con.createStatement(); int i=st.executeUpdate("insert into data1 values ('"+name+"','"+address+"')"); con.close(); out.println("<html><head><title>Successfull</title></head>"); out.println("<h1><center>Successful</center></h1><body><center><p>Data Inserted Succesfully</p></center>"); out.println("</body></html>"); } catch(Exception e) { System.out.println(e); } %>

You might also like