0% found this document useful (0 votes)
5 views5 pages

JSP and JavaBeans Customer Management

The document contains JSP and Java classes for handling student and customer data. It includes a JSP page that uses a JavaBean for a student and another JSP page for customer transactions, which inserts customer data into a MySQL database and forwards to success or failure pages based on the transaction result. The Customer class manages customer information and database interactions, while the Students class handles student names.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

JSP and JavaBeans Customer Management

The document contains JSP and Java classes for handling student and customer data. It includes a JSP page that uses a JavaBean for a student and another JSP page for customer transactions, which inserts customer data into a MySQL database and forwards to success or failure pages based on the transaction result. The Customer class manages customer information and database interactions, while the Students class handles student names.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Demo.

jsp

<jsp:useBean id="Bean1" class="[Link]">

<jsp:setProperty name = "Bean1" property ="name" value ="Zara"/>

<jsp:getProperty name = "Bean1" property = "name"/>

</jsp:useBean>

[Link]

package Bean;

public class Students {

public Students() {

private String name;

public String getName() {

return name;

public void setName(String name) {

[Link] = name;

}
[Link]

package javaskool;
import [Link].*;
import [Link].*;
import [Link].*;

public class Customer implements Serializable


{

private String custID;


private String custName;
private int storeCust;

public String getCustID() {


return custID;
}

public void setCustID(String custID) {


[Link] = custID;
}

public String getCustName() {


return custName;
}

public void setCustName(String custName) {


[Link] = custName;
}

public int setStoreCust()


{
try{
[Link]("[Link]");
Connection
con=[Link]("jdbc:mysql://localhost:3306/db1","root","root");
PreparedStatement pstmt=null;
String query=null;
query="insert into Customer values(?,?)";
pstmt=[Link](query);
[Link](1,custID);
[Link](2,custName);

int i=[Link]();

[Link]=i;
}
catch(Exception e)
{
}
return storeCust;
}
}

[Link]

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


<%@ page import="[Link].*" %>
<%@ page import="[Link]" %>
<html>
<head>
<title>JSP and JavaBean</title>

<%-- create an instance of Customer class --%>


<jsp:useBean id="Customer" class="[Link]">
<jsp:setProperty name = "Customer" property ="custID" value ="C12"/>
<jsp:setProperty name = "Customer" property ="custName" value ="Archana"/>
<jsp:getProperty name = "Customer" property = "custID"/>
<jsp:getProperty name = "Customer" property = "custName"/>

</jsp:useBean>

</head>
<body>

<%
int x=[Link]();

if(x>=1)
{
%>
<jsp:forward page="[Link]" />
<%

}
else
{
%>
<jsp:forward page="[Link]" />
<%

}
%>
</body>
</html>

[Link]
<%

[Link]("<html>");
[Link]("<Body>");
[Link]("<B><center>Thank you for purchasing with us....</center><b><br><br>");
[Link]("</Body>");
[Link]("</html>");

%>

[Link]

<%

[Link]("<html>");
[Link]("<Body>");
[Link]("<B><center>Sorry, Your Transaction is failed....</center><b><br><br>");
[Link]("</Body>");
[Link]("</html>");

%>

You might also like