Sunteți pe pagina 1din 78

WWW.VIDYARTHIPLUS.

COM
Ex. No. : 1

Date:

Car Show Room Inventory Web Application Using JSP and JDBC

Aim
To develop a car show room inventory web application using JSP and JDBC.

Algorithm
Step 1: Choose File > New Project from the main menu. Under categories select java web,
under the project select web application then click Next.

Step 2: Give a name to the project and specify the project location to a directory on the
computer.

Step 3: In the server and setting panel, specify the Glassfish Server on Tomcat as server
which will be used to run the application.

Step 4: In the java EE version field, select Java EE5 click Finish.

Step 5: Create pages index.jsp and response.jsp and insert code for user interface.

Step 6: Create a style sheet to enhance to the design of the web page.

Step 7: Insert code to prepare communication between the application and database.

Step 8: Save project and run the application.

SOURCE CODE

index.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link rel="stylesheet" type="text/css" href="carshowroom.css">

<title>CarShowRoom Inventory</title>

1
WWW.VIDYARTHIPLUS.COM
</head>

<body>

<h1> Welcome To Honda Showroom! </h1>

<table border="0">

<thead>

<tr>

<th> Honda car India is a subsidiary of the honda of japan for the
production, marketing and export of passenger car in india</th>

</tr>

</thead>

<tbody>

<tr>

<td>To view details of car models, select an option below:</td>

</tr>

<tr>

<td>

<form action="response.jsp" method="POST">

<strong>select an option:</strong>

<select name="car_id">

<option>Honda City</option>

<option>Honda civic</option>

</select>

<input type="submit" value="Submit" />

</form> </td>

</tr>

</tbody>

</table>
2
WWW.VIDYARTHIPLUS.COM
</body>

</html>

response.jsp
<%@page import="java.sql.DriverManager"%>

<%@page language="java" session="true" isThreadSafe="true"contentType="text/html"


pageEncoding="UTF-8"%>

<%@page import="java.sql.*" %>

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link rel="stylesheet" type="text/css" href="carshowroom.css">

<title>Car Details</title>

</head>

<body>

<table border="0">

<thead>

<tr>

<th>Honda Cars India</th>

</tr>

</thead>

<tbody>

<tr>

<td>

<%

try {

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
3
WWW.VIDYARTHIPLUS.COM
Connection con =
DriverManager.getConnection("jdbc:odbc:HondaCar", "", "");

Statement stmt = con.createStatement();

String name=request.getParameter("car_id");

String s = "select * from car_details where cname='"+name+"'";

ResultSet r = stmt.executeQuery(s);

if (r.next()) {

out.println("Model Name:" + r.getString("cname"));

out.println("</td></tr>");

out.println("<tr><td>");

out.println("Cost:" + r.getString("cost"));

out.println("</td></tr>");

out.println("<tr><td>");

out.println("Milage:"+r.getString("milage"));

out.println("</td></tr>");

out.println("<tr><td>");

out.println("Color:"+r.getString("color"));

con.close();

} catch (Exception ex) {

out.println(ex);

%>

</tbody>

</table>

</body>

</html>
4
WWW.VIDYARTHIPLUS.COM

style.css
body

font-family:Veranda,Arial,Sans-serif;

font-size: smaller;

padding:50px;

color:#555;

h1{

text-align: left;

letter-spacing: 6px;

font-size: 1.4em;

color:#be7429;

font-weight:normal;

widht:450px;

table{ widht:580px;

padding:10px;

background-color: #c4e7e0;

th{

text-align: left;

border-bottom: 1px solid;

5
WWW.VIDYARTHIPLUS.COM
}

td{

padding: 10px;

OUTPUT:-

6
WWW.VIDYARTHIPLUS.COM
Result
Thus the above program car show room inventory was executed successfully
using JSP and JDBC connectivity.

Ex. No. : 2

Date:

Real Estate Web Application Using JSP Servlet and JDBC

Aim
TO develop a real estate web application using JSP and JDBC connectivity.

Algorithm

Step 1: Choose File > New Project from the main menu. Under categories select java web,
under the project select web application then click Next.

Step 2: Give a name to the project and specify the project location to a directory on the
computer.

Step 3: In the server and setting panel, specify the Glassfish Server on Tomcat as server
which will be used to run the application.

Step 4: In the java EE version field, select Java EE5 click Finish.

Step 5: Create the index.jsp and then select server database the select new connection and
name as 172.18.1.279 & port number 1521.

Step 6: Select the jar file and open and provider service id as orcl & username: HR &
Password: HR.

Step 7: Create table Suitable name and to give the Field name.

Step8: TO Sort the code to prepare communication between the application and
databases.

Step 9: Save project and run the application.

7
WWW.VIDYARTHIPLUS.COM

Source code

Index.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>JSP Page</title>

</head>

<body>

<form action="./realestate" method="POST">

<table border="0">

<thead>

<tr>

<th>Srinitha Real estate was constructed by Chennai city..</th>

</tr>

</thead>

<tbody>

<tr>

<td>select your Choice:<select name="type">

<option>Rental</option>

8
WWW.VIDYARTHIPLUS.COM
<option>Own</option>

</select>

</td>

</tr>

<tr>

<td>select your Style<select name="type">

<option>Individual</option>

<option>Apartment</option>

</select>

</td>

</tr>

<tr>

<td>select your Facility:<select name="type">

<option>Duplex</option>

<option>Semi-Duplex</option>

</select>

</td>

</tr>

</tbody>

</table>

<input type="Submit" value="Submit" name="Submit"/>

</form>

</body>

</html>

Table creation
select * from realestate17;

9
WWW.VIDYARTHIPLUS.COM
insert into realestate17

(OWNER_NAME,RENTAL,APARTMENT,DUPLEX,LOCATION,SECURITY,WATE
R- FACILITY)

values('Ranjini','Rental','Apartment','Duplex','Tirupur'available,Available);

insert into realestate17

(OWNER_NAME,RENTAL,APARTMENT,DUPLEX,LOCATION,SECURITY,WATE
R- FACILITY)

values('Ranjitha','Own',Aapartment',Semiduplex','Coimbatore,Not Available,Available ');

insert into realestate17

(OWNER_NAME,RENTAL,APARTMENT,DUPLEX,LOCATION,SECURITY,WATE
R-FACILITY)

values('Nitha','Rental','Individual','Duplex','Chennai, Available,Available ');

Myservlet.jsp
import java.io.IOException;

import java.io.PrintWriter;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import java.sql.*;

public class MyServlet extends HttpServlet

protected void processRequest(HttpServletRequest request, HttpServletResponse


response)

throws ServletException, IOException

String r_o = request.getParameter("r_o");

String i_a = request.getParameter("i_a");


10
WWW.VIDYARTHIPLUS.COM
String d_s = request.getParameter("d_s");

PrintWriter pw = response.getWriter();

try

Class.forName("oracle.jdbc.driver.OracleDriver");

Connection con =
DriverManager.getConnection("jdbc:oracle:thin:@172.18.1.249:1521:orcl",
"hr", "hr");

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery("select * from realestate17");

while (rs.next())

String owner = rs.getString("OWNERNAME").trim();

String rental = rs.getString("RENTAL_OWN").trim();

String indiv = rs.getString("INDUSTRIAL_APARTMENT").trim();

String duplex = rs.getString("DUPLEX_SEMIDUPLEX").trim();

String loc = rs.getString("LOCATION").trim();

String water = rs.getString("WATER_FACILITY").trim();

String security = rs.getString("SECURITY").trim();

pw.println("<b>owner:" + owner + "</b><br>");

response.setContentType("text/html");

pw.println("<HTML>");

pw.println("<head><title>location</title>");

pw.println("<head><body>");

pw.println("<b>owner:" + owner + "</b><br>");

pw.println("<b>Rental/Own:" + rental + "</b><br>");

pw.println("<b>Individual/Apaartment:" + indiv + "</b><br>");

11
WWW.VIDYARTHIPLUS.COM
pw.println("<b>Duplex/SemiDuplex:" + duplex + "</b><br>");

pw.println("<b>Location:" + loc + "</b><br>");

pw.println("<b>Water:" + water + "</b><br>");

pw.println("<b>Security:" + security + "</b><br>");

pw.println("</body></html");

pw.close();

con.close();

catch (Exception e)

System.out.println(e);

Web.xml
<?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<servlet>

<servlet-name>realestate</servlet-name>

<servlet-class>MyServlet</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>realestate</servlet-name>

<url-pattern>/realestate</url-pattern>

</servlet-mapping>
12
WWW.VIDYARTHIPLUS.COM
<session-config>

<session-timeout>

30

</session-timeout>

</session-config>

<welcome-file-list>

<welcome-file>index.jsp</welcome-file>

</welcome-file-list>

</web-app>

Stylesheet.css
body{

font-family: verdana,Arial,sans_serif;

font-size: smaller;

padding:50px;

color: #555; }

h1{

text-align: legt;

letter-spacing: 6px;

font-size: 1.4em;

color:#be7249;

font-weight: normal;

width:450px; }

table{

width: 580px;

padding: 10px;

background-color: #555; }

13
WWW.VIDYARTHIPLUS.COM
th{

text-align: left;

border-bottom: Ipx solid; }

td{

padding:10px;

Output

Index.jsp

Myservlet.jsp

14
WWW.VIDYARTHIPLUS.COM

Result
Thus the above program was executed and appropriate output has been verified
successfully.

Ex. No. : 3

Date:

Login Web Application Authentication Using LDAP

Aim
To Develop a Login Web Application Authenticates Using LDAP attributes.

Algorithm
Step 1: Start OpenDS Software by clicking Control Panel .bat.

Step2: Create Login Page to receive user input.

Step 3: TO Connect LDAP Server using driver com.sun.jndi.ldap.LdapCtxFactory.

Step 4: Apply the security Authentication mechanism Simple to the application.

Step 5: Level search Scope Implemented in SUBTREE_SCOPE;

Step 6: Apply the Style sheet to enhance the appearance of webpage.


15
WWW.VIDYARTHIPLUS.COM
Step 7: Save the project and run the application.

Source code

Index.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@page import="java.sql.*"%>

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link rel="stylesheet" type="text/css" href="style.css">

<title>JSP Page</title>

</head>

<body><h1> Welcome to login form</h1>

<table border="0">

<tr><td>

<form action="response.jsp" method="POST">

<strong><input type="Username" name="nitha" value=" Username " />

<input type="password" name=" password " value=" password " />

<input type="submit" value="submit" name="submit"/>

</form></td></tr>

</table>

</body>

</html>

Response.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>

16
WWW.VIDYARTHIPLUS.COM
<%@page import="java.util.Hashtable"%>

<%@page import="javax.naming.Context"%>

<%@page import="java.util.Enumeration"%>

<%@page import="javax.naming.directory.*"%>

<%@page import="javax.naming.*"%>

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link rel="Stylesheet" type="text/css" href="style.css">

<title>JSP Page</title>

</head>

<body>

<div id="page-wrap">

<table> <tr> <td>

<% String pwd = request.getParameter("password");

try {

Hashtable env = new Hashtable();

env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldapCtxFactory");

env.put(Context.PROVIDER_URL, "ldap://Localhost:389");

env.put(Context.SECURITY_AUTHENTICATION, "simple");

env.put(Context.SECURITY_PRINCIPAL, "cn=Directory Manager");

env.put(Context.SECURITY_CREDENTIALS, pwd);

DirContext ctx = new InitialDirContext(env);

SearchControls constraints = new SearchControls();

constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
17
WWW.VIDYARTHIPLUS.COM
NamingEnumeration r = ctx.search("dc=example,dc=com",
"(sn=James Holms)", constraints);

while (r != null) {

SearchResult sr = (SearchResult) r.next();

String dn = sr.getName();

out.println("</td></tr><tr><td>Welcome " + dn);

out.println("</td></tr>");

} catch (Exception e) {

System.out.println(e);

%>

</table>

</div>

</body>

</html>

Stylesheet.css
body {

background:#2c3381;

color:#FF86c1;

font-family: verdana,Arial,sans-serif;

margin:0;

#page-wrap {

margin-left: 30em;

margin-right: 6em;
18
WWW.VIDYARTHIPLUS.COM
margin-top: 13em;

tr {

margin-top: 20em;

background-color: #cd6889;

border-radius: 0px3px3px0px;

color:white;

margin-bottom: 1em;

padding:0 16px;

width:300px;

td {

padding-left: 5px;

text-align: center;

Output

Index.jsp

19
WWW.VIDYARTHIPLUS.COM

Response.jsp

Result
Thus the above program was executed and appropriate output has been verified
successfully.

Ex. No. : 4

Date:

Java Application to Add, Delete & Modify LDAP Attributes


20
WWW.VIDYARTHIPLUS.COM
Aim
To Develop a Web Application Authenticates in user details for add, delete and
modify entry to authenticates Using LDAP server.

Algorithm
Step 1: Start OpenDS Software by clicking Control Panel .bat.

Step2: Create Login Page to receives user input.

Step 3: TO Connect LDAP Server using driver com.sun.jndi.ldap.LdapCtxFactory.

Step 4: To Apply the security Authentication mechanism Simple to the application.

Step 5: Level search Scope Implemented in SUBTREE_SCOPE;

Step 6: To write the coding for add in attr.add (Jamesholmes) in the email ID.

Step 7: To write the coding for delete in attr.clear ();

Step 8: Apply the Style sheet to enhance the appearance of webpage.

Step 9: Save the project and run the application.

Source Code:
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@page import ="java.util.Hashtable"%>

<%@page import="javax.naming.Context"%>

<%@page import="java.util.Enumeration"%>

<%@page import="javax.naming.directory.*"%>

<%@page import="javax.naming.*"%>

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link rel="stylesheet" type="text/css" href="style.css">

<title>Login Details</title>
21
WWW.VIDYARTHIPLUS.COM
</head>

<body>

<table>

<tr><td>

<%

String pwd = request.getParameter("password");

try {

Hashtable env = new Hashtable();

env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");

env.put(Context.PROVIDER_URL, "ldap://localhost:389");

env.put(Context.SECURITY_AUTHENTICATION, "simple");

env.put(Context.SECURITY_PRINCIPAL, "cn=Directory Manager");

env.put(Context.SECURITY_CREDENTIALS, pwd);

DirContext ctx = new InitialDirContext(env);

SearchControls constraints = new SearchControls();

constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);

NamingEnumeration r = ctx.search("dc=example,dc=com",
"(sn=Holmes)", constraints);

while (r != null) {

SearchResult sr = (SearchResult) r.next();

String dn = sr.getName();

out.println("</td></tr><tr><td>" );

Attributes attrs=sr.getAttributes();

for(NamingEnumeration ne =
attrs.getAll();ne.hasMoreElements();)

Attribute attr =(Attribute) ne.next();


22
WWW.VIDYARTHIPLUS.COM
String attrID =attr.getID();

//Deleting the attribute value of


TelephoneNumber

if(attrID.equals("telephoneNumber"))

attr.clear();

out.println("</td></tr>");

//Adding an attribute value to E-Mail

if(attrID.equals("mail"))

attr.add("jamesholmes@gmail.com");

out.println("</td></tr><tr><td>");

out.println(attrID+":");

for(Enumeration vals=attr.getAll();vals.hasMoreElements();)

out.println("\t"+vals.nextElement());

out.println("</td></tr>");

out.println("</td></tr><tr><td>");

out.println("</td></tr>");

} catch (Exception e) {

System.out.println(e); } %>

</table> < /body> </html>


23
WWW.VIDYARTHIPLUS.COM
Stylesheet.css
body {

background:#2c3381;

color:#FF86c1;

font-family: verdana,Arial,sans-serif;

margin:0;

#page-wrap {

margin-left: 30em;

margin-right: 6em;

margin-top: 13em;

tr {

margin-top: 20em;

background-color: #cd6889;

border-radius: 0px3px3px0px;

color:white;

margin-bottom: 1em;

padding:0 16px;

width:300px;

td {

padding-left: 5px;

text-align: center; }

24
WWW.VIDYARTHIPLUS.COM
Output: Details of the user

After adding an addition attribute value to Email and deleting the value of telephone

number.

Result

Thus the above program was executed and appropriate output has been verified
successfully.

Ex. No. : 5

25
WWW.VIDYARTHIPLUS.COM
Date:

Student Identity Management Web Application Using Struts

Aim
To create a student Identity management web application using struts classes.

Algorithm
Step 1: Choose File > New Project from the main menu. Under categories select java web,
under the project select web application then click Next.

Step 2: Give a name to the project and specify the project location to a directory on the
computer.

Step 3: In the server and setting panel, to select the Struts framework to create login.jsp.

Step 4: To create the struts pages for success.jsp and success1.jsp and final to create
ActionForm

Step 5: To type the Login form in the class name to select the com.myapp.struts.packages
to add files and to create the access method to user ALT+ Insert.

Step 6: To create the Actionclass to give the name for login Action to create the package
in dropdown list.

Step 7: To delete the Back Forward slash and resource filed and set scope request,
Deselect the validation form Bean.

Step 8: To open the struts.config.xml in source editor to choose any places in the struts >
Add forward

Step 9: To configure using web.xml to write code for <welcome_file> login.jsp


</welcome_file>

Step 10 : To save project and rum the application.

26
WWW.VIDYARTHIPLUS.COM
Login.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>

<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link rel="stylesheet" type="text/css" href="stylesheet.css">

<title>Welcome to login page</title>

</head>

<body>

<h1>Welcome to login page</h1>

<html:form action="/login" method="POST">

<table border="0">

<tbody>

<tr ><td colspan="2" > <bean:write name="LoginForm" property ="error"


filter="false"/></td></tr>

<tr>

<td>Enter Your id:</td>

<td><html:text property="id"/></td>

</tr>

<tr>

<td>Enter your password:</td>

<td><html:text property="password"/></td>

</tr>
27
WWW.VIDYARTHIPLUS.COM
<tr>

<td></td>

<td><b><html:submit value="LOGIN"/></b></td>

</tr>

</tbody>

</html:form>

</body>

</html>

Success.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link rel="stylesheet" type="text/css" href="stylesheet.css">

<title>Login Success Page</title>

</head>

<body>

<h1><b>Congratulations!!!</h1></b>

<p><b>You have successfully logged in.</p></b>

<table>

<tr>

<td>

Personal details

</td>

28
WWW.VIDYARTHIPLUS.COM
</tr>

<tr>

<td>

Name:Ranjitha

</td>

</tr>

<tr>

<td>

Class:3rd Year

</td>

</tr>

<tr>

<td>

Branch:MCA

</td>

</tr>

<tr>

<td>

College Name:Dr.N.G.P.IT

</td>

</tr>

<tr>

<td>

Place:Coimbatore

</td>

29
WWW.VIDYARTHIPLUS.COM
</tr>

<tr>

<td>

Pin code:605701

</td>

</tr>

<tr>

<td></td>

</tr>

</table>

</body>

</html>

Success1.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link rel="stylesheet" type="text/css" href="stylesheet.css">

<title>JSP Page</title>

</head>

<body>

<I><h1>Congratulations!!!</h1></I>

</body>

<table border="0">

<tr>

30
WWW.VIDYARTHIPLUS.COM
<td>

<b><center>LIBRARY DETAILS</center></b>

</td>

</tr>

<tr>

<td>

Name:ranjitha

</td>

</tr>

<tr>

<td>

Baranch:MCA

</td>

</tr>

<tr>

<td>

Name of the Book:J2EE complete reference

</td>

</tr>

<tr>

<td>

Name of the Book:C++ complete reference

</td>

</tr>

<tr>

<td>

31
WWW.VIDYARTHIPLUS.COM
Name of the Book:Java complete reference

</td>

</tr>

<tr>

<td>

Name of the Book:C complete reference

</td>

</tr>

<tr>

<td>

Name of the Book: Statistical complete reference

</td>

</tr>

<tr>

<td>

Name of the Book:Skills complete reference

</td>

</tr>

</table>

</html>

Login form
package com.myapp.struts;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;

import org.apache.struts.action.ActionMapping;

import org.apache.struts.action.ActionMessage;

32
WWW.VIDYARTHIPLUS.COM
public class LoginForm extends org.apache.struts.action.ActionForm {

private String name;

private String id;

public String getId() {

return id;

public void setId(String id) {

this.id = id;

public String getPassword() {

return password;

public void setPassword(String password) {

this.password = password;

private String password;

private String error;

public String getError() {

return error;

public void setError() {

this.error = "<span style='color:red'>please provide valid entries</span>";

public String getName() {

return name;

33
WWW.VIDYARTHIPLUS.COM
}

public void setName(String string) {

name = string;

public LoginForm() {

super();

public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {

ActionErrors errors = new ActionErrors();

if (getName() == null || getName().length() < 1) {

errors.add("name", new ActionMessage("error.name.required"));

// TODO: add 'error.name.required' key to your resources

return errors;

Login action
package com.myapp.struts;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;

import org.apache.struts.action.ActionForward;

import org.apache.struts.action.ActionMapping;

public class LoginAction extends org.apache.struts.action.Action {

34
WWW.VIDYARTHIPLUS.COM
private static final String SUCCESS = "success";

private static final String SUCCESS1 = "success1";

private static final String FAILURE= "failure";

public ActionForward execute(ActionMapping mapping, ActionForm form,

HttpServletRequest request, HttpServletResponse response)

throws Exception {

LoginForm formBean=(LoginForm) form;

String id=formBean.getId();

String password=formBean.getPassword();

String sub=id.substring(2,5);

formBean.setId(sub);

if(sub.equals("MCA"))

return mapping.findForward(SUCCESS);

else if(sub.equals("LIB"))

return mapping.findForward(SUCCESS1);

else

return mapping.findForward(FAILURE);

} }

Struts config.xml

35
WWW.VIDYARTHIPLUS.COM
<?xml version="1.0" encoding="UTF-8" ?>

<struts-config>

<form-beans>

<form-bean name="LoginForm" type="com.myapp.struts.LoginForm"/>

</form-beans>

<global-exceptions>

</global-exceptions>

<global-forwards>

<forward name="success1" path="/success1.jsp"/>

<forward name="failure" path="/login.jsp"/>

<forward name="success" path="/success.jsp"/>

</global-forwards>

<action-mappings>

<action name="LoginForm" path="/login" scope="request"


type="com.myapp.struts.LoginAction" validate="false">

<forward name="SUCCESS" path="/login.jsp"/>

</action>

<action path="/Welcome" forward="/welcomeStruts.jsp"/>

</action-mappings>

<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>

<message-resources parameter="com/myapp/struts/ApplicationResource"/>

<plug-in className="org.apache.struts.tiles.TilesPlugin" >

<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />

<set-property property="moduleAware" value="true" />

</plug-in>

<plug-in className="org.apache.struts.validator.ValidatorPlugIn">

<set-property
36
WWW.VIDYARTHIPLUS.COM
property="pathnames"

value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>

</plug-in> </struts-config>

Web.xml
<?xml version="1.0" encoding="UTF-8"?>

<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee"


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">

<servlet>

<servlet-name>action</servlet-name>

<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>

<init-param>

<param-name>config</param-name>

<param-value>/WEB-INF/struts-config.xml</param-value>

</init-param>

<init-param>

<param-name>debug</param-name>

<param-value>2</param-value>

</init-param>

<init-param>

<param-name>detail</param-name>

<param-value>2</param-value>

</init-param>

<load-on-startup>2</load-on-startup>

</servlet>

<servlet-mapping>

<servlet-name>action</servlet-name>
37
WWW.VIDYARTHIPLUS.COM
<url-pattern>*.do</url-pattern>

</servlet-mapping>

<session-config>

<session-timeout>

30

</session-timeout>

</session-config>

<welcome-file-list>

<welcome-file>login.jsp</welcome-file>

</welcome-file-list>

</web-app>

Stylesheet.jsp
body{

font-family:bjpr;

font-size: larger;

padding: 50px;

color: darkviolet

background-color beige;

h1{

text-align:center;

letter-spacing: 6px;

frnt: size.1.4em;

color: #be7429;

font-weight: normal;

width: 450px;

38
WWW.VIDYARTHIPLUS.COM
font-style: italic;

table{

width: 580px;

padding: 10px;

background-color: burlywood;

th{

text-align: center;

border-bottom: 1px solid;

td{

padding: 10px;

OUTPUT

Login Page

39
WWW.VIDYARTHIPLUS.COM
Personal Details

Login Library

Library Details

40
WWW.VIDYARTHIPLUS.COM

Result
Thus the above program was executed and appropriate output has been verified
successfully.

Ex. No. : 6

Date:

Online Bookstore Using Validation Control in ASP.Net

Aim
To write a program for online book store application using ASP.Net

Algorithm
Step 1: Start => Microsoft visual studio 2008 => New Project => VC# and Asp.Net
application => to give a name for Name Panel Online.aspx.

Step 2: To create the design page for student information to using the validation control,
like

Required Field Validator

Custom Validator

41
WWW.VIDYARTHIPLUS.COM
Compare Validator

Regular Expression Validator

Step 3: All the validation control should be using the control to validate key.

Step 4: If the validation is successful then go to book.aspx &The book details shown the
book page.

Step 5: Tamil book and English book details the coding for Button click in
Response.Redirect.Tamil.aspx & Response.Redirect.English.aspx

Step 5: save the project and run the program.

Source Code

Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="online._Default" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
#form1
{
font-size: small;
font-weight: 700;
font-style: italic;
text-align: center;
}
.style1
{
font-size: x-large;
font-style: normal;
}
.style3
{
font-style: normal;
font-size: large;
}
.style4
{
text-decoration: underline;
}
42
WWW.VIDYARTHIPLUS.COM
</style>
</head>
<body bgcolor="#66ffcc" style="font-size: large">
<form id="form1" runat="server">
<span class="style1">
<br />
<span class="style4">ONLINE BOOK STORE</span><br />
<br />
<br />
</span>

<asp:Panel ID="Panel1" runat="server" Height="248px" Width="533px">


<p
style="text-align: left; font-weight: 700; font-size: medium">
&nbsp;</p>
<p style="text-align: left; font-weight: 700; font-size: medium">
<span class="style3">E-mail ID&nbsp;&nbsp;&nbsp;
:</span><asp:TextBox ID="TextBox1"
runat="server" Height="23px"
style="font-weight: 700; font-style: italic; margin-left: 66px;"
Width="147px"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server"
ControlToValidate="TextBox1" ErrorMessage="Enter your Email Id"
ValidationExpression="\S+@\S+\.\S+"></asp:RegularExpressionValidator>
</p>
<p style="text-align: left; font-weight: 700; font-size: medium">
<span class="style3">Password&nbsp;&nbsp;&nbsp; :</span><asp:TextBox
ID="TextBox2" runat="server" style="font-weight: 700; margin-left: 66px;"
TextMode="Password" Height="24px" Width="147px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ErrorMessage="Enter Your Password" ControlToValidate
="TextBox2"></asp:RequiredFieldValidator>
</p>
<p style="text-align: left; font-weight: 700; font-size: medium">
&nbsp;</p>
<p style="text-align: left; font-weight: 700; font-size: medium">
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
style="font-size: large; font-weight: 700; font-family: 'Times New
Roman', Times, serif; margin-left: 174px;"
Text="Submit" Width="139px" />
</p>
<p style="text-align: left; font-weight: 700; font-size: medium">
&nbsp;</p>
</asp:Panel>
<p style="text-align: left; font-weight: 700; font-size: medium">
&nbsp;</p>
<p style="text-align: left; font-weight: 700; font-size: medium">
43
WWW.VIDYARTHIPLUS.COM
&nbsp;</p>
<p style="text-align: left; font-weight: 700; font-size: medium">
&nbsp;</p>
</form>
</body> </html>

Default.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace bookstore
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

protected void Button1_Click(object sender, EventArgs e)


{
Response.Redirect("StudentInfo.aspx");
}
}

Student.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="studinfo.aspx.cs"
Inherits="online.studinfo" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.style1
{
text-align: center;
font-size: xx-large;
44
WWW.VIDYARTHIPLUS.COM
}

</style>
</head>
<body bgcolor="#ffff99" style="font-weight: 700; font-size: medium">
<form id="form1" runat="server">
<div class="style1">
Student Information</div>
<asp:Panel ID="Panel1" runat="server" BorderStyle="Solid" Height="317px"
style="margin-left: 247px; margin-top: 135px" Width="491px">
<p>
Register
No:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ErrorMessage="To Enter Your Register no"
ControlToValidate ="TextBox1"></asp:RequiredFieldValidator>
</p>
<p>
Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ErrorMessage="Enter your valid Name"
ControlToValidate ="TextBox2"></asp:RequiredFieldValidator>
</p>
<p>
Dept mail:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server"
ErrorMessage="Enter the correct dept" ControlToValidate ="TextBox3"
ValidationExpression ="\S+@\S+\.\S+"></asp:RegularExpressionValidator>
</p>
<p>
Login Password:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server"
ErrorMessage="Password does not correct" ControlToValidate ="TextBox4"

ControlToCompare ="TextBox2"></asp:CompareValidator>
</p>
<p>

Retype password&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox5" runat="server" ontextchanged
="TextBox5 _TextChanged"> </asp:TextBox>
45
WWW.VIDYARTHIPLUS.COM
<asp:CustomValidator ID="CustomValidator1" runat="server"
ErrorMessage="Invalid user"
onservervalidate="CustomValidator1_ServerValidate"
ControlToValidate="TextBox5"></asp:CustomValidator>
</p>
<p style="margin-left: 160px">
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
style="font-weight: 700; font-style: italic; height: 26px"
Text="Book Details" />
</p>
</asp:Panel>
<p>
</p>
</form>
</body>
</html>
StudentInfo.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace Online
{
public partial class StudentInfo: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

protected void CustomValidator2_ServerValidate1(object source,


ServerValidateEventArgs args)
{
String name = TextBox8.Text;
if (name == "Srinitha")
args.IsValid = true;
else
args.IsValid = false;
46
WWW.VIDYARTHIPLUS.COM

}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("bookdetails.aspx");
}
}

Bookdetails.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="book.aspx.cs"
Inherits="online.WebForm1" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
#form1
{
text-align: center;
font-weight: 700;
font-style: italic;
font-size: x-large;
}
.style1
{
font-size: xx-large;
}
</style>
</head>
<body bgcolor="#ffff66" style="font-weight: 700; font-size: medium;">
<form id="form1" runat="server">
<span class="style1"
style="background-repeat: repeat; border-style: dashed; border-width: thin">Book
Details</span><br /><br /><br />

<asp:Panel ID="Panel1" runat="server" BackColor="#FFCCCC" BorderStyle="Groove"


BorderWidth="20px" Height="181px" Width="306px">
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
style="font-weight: 700; margin-left: 0px; font-size: medium; font-family: 'Book
Antiqua';"
Text="Tamil Book Details" Width="197px" />
<br /> <br />
<asp:Button ID="Button2" runat="server" onclick="Button2_Click1"
style="font-weight: 700; margin-left: 6px; font-size: medium; font-family: 'Book
Antiqua';"
Text="English Book Details " Height="34px" Width="204px" />
47
WWW.VIDYARTHIPLUS.COM
<br /><br />
<br /><br />
</asp:Panel>
<br /> <br /> <br />
</form>
</body>
</html>
BookDetails.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace online
{
public partial class bookdetails : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("Tamildetails.aspx");
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("Englishdetails.aspx");
}
}

Tamildetails.aspx

<%@ Page Language="C#" AutoEventWireup="true"


CodeBehind="Tamildetails.aspx.cs" Inherits="online.Tamildetails" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
48
WWW.VIDYARTHIPLUS.COM
</head>
<body bgcolor="#99ccff" style="font-weight: 700; font-size: large">
<body<body bgcolor="#99FFCC" style="font-weight: 700; font-size: large" >
<form id="form2" runat="server">
<p>
<asp:Label ID="Label1" runat="server" BorderStyle="Ridge" Font-Bold="True"
Height="27px" style="text-align: right; font-size: x-large; margin-left: 370px"
Text="Tamil Book Details" Width="213px"></asp:Label>
</p>
Book Id: <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox1" runat="server" style="margin-left: 77px"
Width="137px"></asp:TextBox>
</b>
<p>
&nbsp;Name Of the Book:<asp:TextBox ID="TextBox2" runat="server"
style="margin-left: 37px" Width="138px"></asp:TextBox>
&nbsp;</p>
<p>
Book Author:<asp:TextBox ID="TextBox3" runat="server" style="margin-left:
86px"
Width="133px"></asp:TextBox> </p>
<p>
Price of the Book:<asp:TextBox ID="TextBox4" runat="server"

style="margin-left: 55px" Width="136px"></asp:TextBox> </p>


<p>
Publisher of the Book:<asp:TextBox ID="TextBox5" runat="server"
style="margin-left: 23px" Width="136px"></asp:TextBox> </p>
<p>
Publishing&nbsp; Date:&nbsp;&nbsp;
<asp:TextBox ID="TextBox6" runat="server" style="margin-left: 52px"
Width="137px"></asp:TextBox> </p>
</form>
</body>
</html>

Englishdetails.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="English.aspx.cs"
Inherits="online.English" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body bgcolor="#99FFCC" style="font-weight: 700; font-size: large" >
<form id="form1" runat="server">
<p>
49
WWW.VIDYARTHIPLUS.COM
<asp:Label ID="Label1" runat="server" BorderStyle="Ridge" Font-Bold="True"
Height="27px" style="text-align: right; font-size: x-large; margin-left: 370px"
Text="English Book Details" Width="213px"></asp:Label> </p>
<p>
&nbsp;</p>
<p> &nbsp;</p>
<asp:Panel ID="Panel1" runat="server" BackColor="#FFCCFF" Height="214px"
style="margin-left: 86px" Width="264px">
<br />
<br /><br />
<br /><br />
<br />
<asp:Button ID="Button1" runat="server"
style="margin-left: 85px; font-weight: 700;" Text="Details" Width="90px"
BorderStyle="Groove" ForeColor="#CC0000" onclick="Button1_Click1" />
</asp:Panel>
</form>
</body>
</html>

OUTPUT

50
WWW.VIDYARTHIPLUS.COM
Login
Page

Enter your valid Email ID

51
WWW.VIDYARTHIPLUS.COM
Student Information

Enter the required field

Enter Your Login Password

52
WWW.VIDYARTHIPLUS.COM
Enter Your dept Email ID

Enter Your Dept Mail ID

53
WWW.VIDYARTHIPLUS.COM
Enter Your Login
password

Enter your correct password

54
WWW.VIDYARTHIPLUS.COM
Book Details

Tamil Book Details

55
WWW.VIDYARTHIPLUS.COM

Book Details

English Book Details

Result

56
WWW.VIDYARTHIPLUS.COM
Thus the above program was executed and appropriate output has
been verified successfully

Ex. No. : 7

Date:

Arithmetic Calculation in Web Form Using ASP.Net


Aim

To develop web application in Arithmetic calculation using Asp.Net

Algorithm
Step 1: Start => Microsoft visual studio 2008 => New Project => VC# and Asp.Net
application => to give a name for Name Panel Calci.aspx.

Step 2: To create the Design page for Arithmetic calculation.

Step 3: To write the coding for button click in Addition and Subtraction in the design
page.

Step 4: The source code is auto generated on the label box and text box in the source code
window.

Step 5: Save the Project and Run the program.

Step 6: Stop the Program.

SOURCE CODE

Default.aspx
Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="calculate._Default" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.style1
{
font-family: "Book Antiqua";
font-weight: bold;
}

57
WWW.VIDYARTHIPLUS.COM
.style2
{
font-family: "Book Antiqua";
font-weight: bold;
font-size: medium;
}
.style3
{
font-size: medium;
}
.style4
{
font-family: "Book Antiqua";
font-weight: bold;
font-size: x-large;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:Panel ID="Panel1" runat="server" BackColor="#669900" BorderStyle="Solid"
Height="477px" style="margin-left: 205px; margin-top: 47px" Width="670px">
<span class="style2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
class="style4">Addution and Subtraction
of Two Numbers from the user</span><br class="style2" />
<br class="style2" />
<br class="style2" />

<span class="style2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span


class="style1"><span class="style3">
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
style="margin-left: 199px; font-size: medium; font-weight: 700; font-family:
'Times New Roman', Times, serif;"
Text="ADDITION" Width="144px" />
</span></span>
<br class="style2" />
<br class="style2" />
<br class="style2" />
<span class="style2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span class="style1"><span class="style3">
<asp:Button ID="Button2" runat="server" onclick="Button2_Click"
style="margin-left: 198px; font-size: medium; font-weight: 700; font-family:
'Times New Roman', Times, serif;"
Text="SUBTRACTION" Width="146px" />
</span></span>
</asp:Panel>
</form>
58
WWW.VIDYARTHIPLUS.COM
</body>
</html>

Default.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace calculate
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect(User.aspx);
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect(User1.aspx);
}
}
}

User.aspx
<%Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="calculate._Default"%>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.style1
{
59
WWW.VIDYARTHIPLUS.COM
font-family: "Book Antiqua";
font-weight: bold;
}
.style2
{
font-family: "Book Antiqua";
font-weight: bold;
font-size: medium;
}
.style3
{
font-size: medium;
}
.style4
{
font-family: "Book Antiqua";
font-weight: bold;
font-size: x-large;
}
</style>
</head>

<body>
<form id="form1" runat="server">
<asp:Panel ID="Panel1" runat="server" BackColor="#669900" BorderStyle="Solid"
Height="477px" style="margin-left: 205px; margin-top: 47px" Width="670px">
<span class="style2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
<span class="style4">Addution and Subtraction
of Two Numbers from the user</span><br class="style2" />
<br class="style2" />
<br class="style2" />
<span class="style2">First number for the user
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span>
<span class="style1"><span class="style3">
<asp:TextBox ID="TextBox5" runat="server" Height="33px"
Width="151px"></asp:TextBox>
</span></span>
<br class="style2" />
<br class="style2" />
<span class="style2">Second number for the user&nbsp;&nbsp;&nbsp;
</span><span class="style1">
<span class="style3">
<asp:TextBox ID="TextBox2" runat="server" Height="29px"
style="margin-left: 12px" Width="150px"></asp:TextBox>
</span></span>
<br class="style2" />
<br class="style2" />
60
WWW.VIDYARTHIPLUS.COM
<br class="style2" />
<br class="style2" />
<span class="style2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span class="style2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span class="style1"><span class="style3">
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
style="margin-left: 199px; font-size: medium; font-weight: 700; font-family:
'Times New Roman', Times, serif;"
Text="ADDITION" Width="144px" />
</span></span>
</asp:Panel>
</form>
</body>
</html>

User.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace calculate
{
public partial class _user : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect(Addition.aspx);
}
}
}
Addition.aspx
Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="calculate._Default" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
61
WWW.VIDYARTHIPLUS.COM
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.style1
{
font-family: "Book Antiqua";
font-weight: bold;
}
.style2

{
font-family: "Book Antiqua";
font-weight: bold;
font-size: medium;
}
.style3
{
font-size: medium;
}
.style4
{
font-family: "Book Antiqua";
font-weight: bold;
font-size: x-large;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:Panel ID="Panel1" runat="server" BackColor="#669900" BorderStyle="Solid"
Height="477px" style="margin-left: 205px; margin-top: 47px" Width="670px">
<span class="style2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
6class="style4">Addution and Subtraction
of Two Numbers from the user</span><br class="style2" />
<br class="style2" />
<br class="style2" />
<span class="style2">Result for ADDITION</span><span class="style1"><span
class="style3"><asp:TextBox ID="TextBox3" runat="server" Height="29px"
style="margin-left: 66px" Width="145px"></asp:TextBox>
</span></span>
</asp:Panel>
</form>
</body>
</html>
Addition.aspx.cs
using System;
using System.Collections;
using System.Configuration;
62
WWW.VIDYARTHIPLUS.COM
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;

using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace calculate
{
public partial class _Addition : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
int num1 = Int32.Parse(TextBox1.Text);
int num2 = Int32.Parse(TextBox2.Text);
int sum = num1 + num2;
TextBox3.Text = sum.ToString();
}
}
User1.aspx
Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="calculate._Default" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.style1
{
font-family: "Book Antiqua";
font-weight: bold;
}
.style2
{
font-family: "Book Antiqua";
font-weight: bold;
font-size: medium;
}
.style3

{
63
WWW.VIDYARTHIPLUS.COM
font-size: medium;
}
.style4
{
font-family: "Book Antiqua";
font-weight: bold;
font-size: x-large;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:Panel ID="Panel1" runat="server" BackColor="#669900" BorderStyle="Solid"
Height="477px" style="margin-left: 205px; margin-top: 47px" Width="670px">
<span class="style2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
class="style4">Addution and Subtraction
of Two Numbers from the user</span><br class="style2" />
<br class="style2" />
<br class="style2" />
<span class="style2">First number for the user
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
<span class="style1"><span class="style3">
<asp:TextBox ID="TextBox5" runat="server" Height="33px"
Width="151px"></asp:TextBox>
</span></span>
<br class="style2" />
<br class="style2" />
<span class="style2">Second number for the user&nbsp;&nbsp;&nbsp;
</span><span class="style1">
<span class="style3">
<asp:TextBox ID="TextBox2" runat="server" Height="29px"
style="margin-left: 12px" Width="150px"></asp:TextBox>
</span></span>
<br class="style2" />
<br class="style2" />
<br class="style2" />
<br class="style2" />
<span class="style2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span class="style2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span class="style1"><span class="style3">
<asp:Button ID="Button2" runat="server" onclick="Button2_Click"

style="margin-left: 199px; font-size: medium; font-weight: 700; font-family: 'Times


New Roman', Times, serif;"
Text="SUBTRACTION" Width="144px" />
</span></span>
</asp:Panel>
</form>
64
WWW.VIDYARTHIPLUS.COM
</body>
</html>

User1.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace calculate
{
public partial class _user : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect(Subtraction.aspx);
}
}
}

Subtraction.aspx

Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"


Inherits="calculate._Default" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.style1
{
font-family: "Book Antiqua";
font-weight: bold;
}
.style2
{
65
WWW.VIDYARTHIPLUS.COM
font-family: "Book Antiqua";
font-weight: bold;
font-size: medium;
}
.style3
{
font-size: medium;
}
.style4
{
font-family: "Book Antiqua";
font-weight: bold;
font-size: x-large;
}
</style></head><body>
<form id="form1" runat="server">
<asp:Panel ID="Panel1" runat="server" BackColor="#669900" BorderStyle="Solid"
Height="477px" style="margin-left: 205px; margin-top: 47px" Width="670px">
<span class="style2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
class="style4">Addution and Subtraction
of Two Numbers from the user</span><br class="style2" />
<br class="style2" />
<br class="style2" />
<span class="style2">Result for SUBTRACTION</span><span
class="style1"><span
class="style3"><asp:TextBox ID="TextBox4" runat="server" Height="29px"
style="margin-left: 66px" Width="145px"></asp:TextBox>
</span></span>
</asp:Panel>
</form>
</body>
</html>
Subtraction.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

66
WWW.VIDYARTHIPLUS.COM
namespace calculate
{
public partial class _subtraction : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button2_Click(object sender, EventArgs e)
{
int num1 = Int32.Parse(TextBox1.Text);
int num2 = Int32.Parse(TextBox2.Text);
int sub = num1 - num2;
TextBox4.Text = sum.ToString();
}
}}
OUTPUT

Assign the value

67
WWW.VIDYARTHIPLUS.COM

Result for Addition

68
WWW.VIDYARTHIPLUS.COM
Subtraction

Result for subtraction

69
WWW.VIDYARTHIPLUS.COM

Result
Thus the above program was executed and appropriate output has been verified
successfully.

Ex. No. : 8

Date:

Silver light Application using share point client object model


70
WWW.VIDYARTHIPLUS.COM
Aim
To develop the Silver light Application using share point client object model.

Algorithm
Step 1: To open the Notepad window and type the coding using HTML tags.

Step 2: To give the name in name panel window & save the file using .html extension.

Step 3: To include the HTML header Files and Script Types, to use the Canvas Xmlns.

Step 4: To develop the coding for textbox, Rectangle, Ellipse, & Line and Polygon.

Step 5: To create the <path > and declare the path geometry in the tag file and also close
the </path> tag.

Step 6:Finally close the object and close the HTML header tags.

Step 7: Save the program & run the application.

Source Code:
<html>

<head>

<title>This is my first Silverlight Application developed using


Notepad</title>

</head>

<script type="text/javascript" >

function MouseLeftButtonDownClick(sender, args) {

var x = args.GetPosition(sender).x;

var y = args.GetPosition(sender).y;

// Retrieve a reference to the plug-in

var plugin = sender.getHost();

//Creates XAML content dynamically.

var textblockXaml = '<TextBlock Canvas.Left=" ' + x + '" Canvas.Top="' +


y+

71
WWW.VIDYARTHIPLUS.COM
'" FontSize="18" Text="hello" Foreground="#CCCCCC"/>'

var textblock = plugin.content.CreateFromXaml(textblockXaml);

// Add the XAML fragment as a child of the root Canvas


object.

sender.children.add(textblock); }

</script>

<script type="text/xaml" id ="xamlsource">

<Canvas xmlns =http://schemas.microsoft.com/client/2007 Width="640"


Height="480" Background="Black"
MouseLeftButtonDown="MouseLeftButtonDownClick">

<TextBlock Canvas.Left="4" FontSize="18" Text="First Silverlight Application"


Foreground="#CCCCCC"/>

<Ellipse Canvas.Left="20" Canvas.Top="50" Fill="Orange" Width="200"


Height="80" />

<Rectangle Canvas.Left="250" Canvas.Top="50" Width="80" Height="80"


Fill="Red"/>

<Line Canvas.Left="20" Canvas.Top="100" X1="20" Y1="20" X2="100"


Y2="100" Stroke="Yellow" StrokeThickness="10"/>

<Polygon Canvas.Left="80" Canvas.Top="140" Fill="blue" Stroke="Green"


StrokeThickness="10" Points="20,20 100,100 200,10"/>

<Path>

<Path.Data>

<PathGeometry>

<PathFigure StartPoint="20,20">

<BezierSegment Point1="120,0" Point2="50,300" Point3="200,200"/>

</PathFigure>

</PathGeometry>

</Path.Data>

</Path>

72
WWW.VIDYARTHIPLUS.COM
</Canvas>

</script>

<body>

<object type="application/x-silverlight" id="silverlightControl" width="200%"


height="100%">

<param name="source" value="#xamlsource"/>

</object>

</body>

</html>

Output:

Result
Thus the above program was executed and appropriate output has been verified
successfully.
73
WWW.VIDYARTHIPLUS.COM
Ex. No. : 9

Date:

Silver Light Graphic Control

Aim
To develop the program for silver light application using Graphic control.

Algorithm
Step 1: To start the program => Microsoft Visual Studio 2010 => File => New Project.

Step 2: Under the categories VC# the templates for silver light application in silver light
control.

Step 3: To give the suitable name for the project & choose the drive to save.

Step 4: To select the chart tool in toolbox & write the coding for mainform.xaml.

Step 5: to declare the variable for sName and tMarks using constructor.

Step 6: To save the project and run the program.

Source Code

Class1.cs
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace SilverlightApplication1
{
public class Class1
{

public Class1() { }
public Class1(string sName, int tMarks)
{
74
WWW.VIDYARTHIPLUS.COM

Name = sName;
Marks = tMarks;

}
public string Name { get; set; }
public int Marks { get; set; }
}
}

MainPage.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
namespace SilverlightApplication1
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();

ObservableCollection<Class1> Report = new ObservableCollection<Class1>


{
new Class1("Uma", 99),
new Class1("Yamuna", 75),
new Class1("Deeban", 30)
};
Student.DataContext = Report;
}
}
}

MainPage.xaml
<UserControl x:Class="SilverlightApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
75
WWW.VIDYARTHIPLUS.COM
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400" xmlns:charting="clr-
namespace:Microsoft.Windows.Controls.DataVisualization.Charting;assembly=Microsoft.
Windows.Controls.DataVisualization">

<Grid x:Name="LayoutRoot" Background="White">

<charting:Chart HorizontalAlignment="Left" Margin="112,91,0,0" Name="Student"


VerticalAlignment="Top" Height="208" >

<charting:PieSeries ItemsSource="{Binding}"
IndependentValueBinding="{Binding Name}"
DependentValueBinding="{Binding Marks}"/>

</charting:Chart>
</Grid>
</UserControl>

Output: PieSeries

76
WWW.VIDYARTHIPLUS.COM

Output: BarSeries

77
WWW.VIDYARTHIPLUS.COM
Result
Thus the above program was executed and appropriate output has been verified
successfully.

78

S-ar putea să vă placă și