WXML Programs
WXML Programs
AIM:
To write a simple xml program and generate DTD program using
netbeans IDE.
PROCEDURE:
<PARTS>
<TITLE>Computer Parts</TITLE>
<PART>
<ITEM>Motherboard</ITEM>
<MANUFACTURER>ASUS</MANUFACTURER>
<MODEL>P3B-F</MODEL>
<COST> 123.00</COST>
</PART>
<PART>
<ITEM>Video Card</ITEM>
<MANUFACTURER>ATI</MANUFACTURER>
<MODEL>All-in-Wonder Pro</MODEL>
<COST> 160.00</COST>
</PART>
</PARTS>
7. Right click on the xml program -> select generate DTD.
OUTPUT:
RESULT:
Thus, the above program was successfully executed and verified.
XML WITH XSL STYLESHEET USING NETBEANS
AIM:
To write a xml program with xsl stylesheet using netbeans.
PROCEDURE:
PROGRAM:
Newxsl.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html"/>
<xsl:template match="/collection">
<html>
<head>
<title>newstylesheet.xsl</title>
</head>
<h1>!!! MOVIES !!!</h1>
<body>
<table border="3" cellpadding="2">
<tr>
<th>TITLE</th>
<th>YEAR</th>
<th>GENRE</th>
</tr>
<xsl:for-each select=" movie">
<tr>
<td><xsl:value-of select="title"/></td>
<td> <xsl:value-of select="year"/></td>
<td> <xsl:value-of select="genre"/></td></tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
New.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="newxsl.xsl" type="text/xsl"?>
<collection>
<movie>
<title>Two States</title>
<year>2014</year>
<genre>Non-Fiction</genre>
</movie>
<movie>
<title>Harry Potter</title>
<year>2005</year>
<genre>Fiction</genre>
</movie>
<movie>
<title>Iron Man</title>
<year>2009</year>
<genre>Comic</genre>
</movie>
</collection>
OUTPUT:
RESULT:
Thus, the above program for xsl stylesheet has been executed and
verified.
DOMPARSER USING NETBEANS
AIM:
To write a java program to develop domparser using Netbeans.
PROCEDURE:
PROGRAM:
Domparser.java
import javax.xml.parsers.*;
import java.io.IOException;
import org.w3c.dom.*;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
catch(ParserConfigurationException e)
{ e.printStackTrace(); }
catch(SAXException e)
{ e.printStackTrace(); }
catch(IOException e)
{ e.printStackTrace(); }
}
}
Dom.xml
<?xml version="1.0" encoding="UTF-8"?>
<people><person id="1">
<firstname>Robert</firstname>
<lastname>DowneyJ</lastname>
</person><person id="2">
<firstname>Bradley</firstname>
<lastname>Sara</lastname>
</person><person id="3">
<firstname>Rajiv Gandhi</firstname>
<lastname>J S</lastname>
</person>
</people>
OUTPUT:
run:
person1:firstname=Robert
person1:lastname=DowneyJ
person2:firstname=Bradley
person2:lastname=Sara
person3:firstname=Rajiv Gandhi
person3:lastname=J S
BUILD SUCCESSFUL (total time: 0 seconds)
RESULT:
Thus, the above program for Domparser has been executed and verified.
DEVELOPING WEB APPLICATIONS IN NETBEANS USING JAVA
AIM:
To develop Web application for displaying user details using Netbeans
IDE.
PROCEDURE:
1. Start->All Programs->NETBEANS IDE.
2. Select File->New Project->Java Web->Web Application.
3. Give the project name as SampleWeb select glassfish server and click the
finish button.
4. In SampleWeb ->select source packages right click select new->java class-
>file name as sample handler ->package as org.mypackage.sample->click
on finish.
5. In samplehandler.java declare the variable and constructor and right
click select refactor
->encapsulate filed.
10. Next drag text input give name as name and click ok.in the text input
tag delete value.
11. Drag the button and give label as ok and type as submit then click
on ok.
16. Select jsp->use bean drag and drop it after body tag of response.jsp
17. In use bean give id as mybean and class as
org.mypackage.sample.samplehandler and scope as session.
18. Then select set bean property drag and place give bean name as
mybean and click on ok.In the set bean tag delete the value.
19. now select get bean property and drag inside of h1 tag (i.e after
hello )give bean name as mybean and property name as name.
21. Enter the name and click ok it brings you the next page.
RESULT:
AIM:
To design GUI for bank application in java using Netbeans IDE.
PROCEDURE:
3. Give Project name as NewBalance ,uncheck the main class and click finish.
4. Select File->New File->Swing GUI Forms->JFrame form.
5. Give file name newbalance and click ok.
6. Now design the balance page with six labels and two text field and button.
7. Change the variable name textfield1 name as credit amount and
textfield2 as debitamount and label as resultbalance .This is done by
performing right click.
8. Insert menu bar with file and edit.under file add sub menu by dragging
menu item and give name as exit.
9. Add the shortcut for exit by double click on it.give ctrl+q as short cut key.
10. Double click on getbalance button and add the following code.
13. Give the input for credit amount and debit amount and click on
getblance button and also check for exit with shortcut.
RESULT:
Thus the GUI design for bank application has been successfully
deployed.
EJB COMPONENT FOR FINDING SQUARE OF A NUMBER
AIM:
To develop EJB component for finding square of a nember using Netbeans
IDE.
PROCEDURE:
3. Give the project name as SampleEJB and click the finish button.
4. Select file menu->New Project->Java EE->Enterprise Application.
5. Give the project name as SampleEJ select glassfish vs as server and click
the finish button.
6. Select SampleEJ-ejb right click and select new sessionbean.
7. Give the EJB name as EJBSession and select session type as stateless give
the package as in and select interface as remote and click the finish
button.
8. Right click on EJBSession select insert code->select add business method.
9. Under Add business method give name as get and return type as int and
click add button give the variable name and the data type and local
interface as remote.
10. Following code will displayed:
RESULT:
Thus the EJB component for finding square has been successfully
executed using Netbeans IDE.
EJB COMPONENTS FOR FINDING POWER VALUE
AIM:
To write a program for EJB components for finding power value.
PROCEDURE:
1. Start->All Programs->NetbeansIDE
2. Select File Menu->New Project->JavaEE->Enterprise application.
3. Give the project name as powerservice select glassfish vs server and click
the finish button.
4. Select the powerservice-ejb right click and select new session.
5. Give the EJB name as powersessionbean and select sessiontype as
stateless and interface as remote give the package name as mypack and
click the finish.
6. Select powersessionbean class insert the business method find power.
7. Right click select insert code option->add business method give the name
as findpower return type as int.
8. Select powerservice-war right click new->servlet.give name as
powerservlet and select add the information method .
9. Now right click inside the program select Insert code->call enterprise
bean->EJBSession-ejb->EJBSession and select interface as remote click on
ok.
10. Select powerservice-war right click new->JSP.give name as
index.jsp.and the form tag and two text field and button using palatte.
11. Deploy and run the project.
PROGRAM:
POWERSESSIONBEAN.JAVA
package mypack;
import javax.ejb.Stateless;
@Stateless
public class powersessionbean implements powersessionbeanRemote {
public int findpower(int x, int y) {
int result=1;
for(int i=0;i<y;i++)
{
result=result*x;
}
return result;
}
POWERSERVLET.JAVA:
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import powerj.powersessionjRemote;
public class powerservletj extends HttpServlet {
@EJB
private powersessionjRemote powersessionj;
protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
int a,b;
a= Integer.parseInt(request.getParameter("xval"));
b=Integer.parseInt(request.getParameter("yval"));
try {
// TODO output your page here
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet powerservletj</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Answer: "+a+"power"+b+" =
"+powersessionj.findpower(a,b)+"</h1>");
out.println("</body>");
out.println("</html>");
} finally {
out.close();
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on
the + sign on the left to edit the code.">
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold> }
INDEX.JSP:
RESULT:
Thus, the above program for finding power value was successfully
executed and verified.
DEVELOPING SIMPLE WEB APPLICATIONS IN NETBEANS USING JAVA
AIM:
To develop simple web application for displaying user details using
Netbeans IDE.
PROCEDURE:
1. Start->All Programs->NETBEANS IDE.
2. Select File->New Project->Java Web->Web Application.
3. Give the project name as asone select glassfish server and click the finish
button.
4. In SampleWeb ->select source packages right click select new->java class-
>file name as ashandler ->package as org.mypackage.sample->click on
finish.
5. In ashandler.java declare the variable and constructor and right click
select refactor
a. ->encapsulate filed.
6. Select get and set method and click refactor.
i.
12.
13. Before input tag type as “Enter your name”, “Enter your
department”, “Enter your college name”.
14. Now select asone project right click->select new->jsp. Give the
project name as response then click finish. Select tools->palatte-
>html/jsp code clips then palatte manager will open.
15. Select jsp->use bean drag and drop it after body tag of response.jsp
16. In use bean give id as mybean and class as
org.mypackage.sample.samplehandler and scope as session.
17. Then select set bean property drag and place give bean name as
mybean and click on ok.In the set bean tag delete the value.
18. Now select get bean property and drag inside of h1 tag (i.e after
hello )give bean name as mybean and property name as name.
19.
21. Enter the name and click ok it brings you the next page.
RESULT:
AIM:
To design GUI for temperature conversion application in java using
Netbeans IDE.
PROCEDURE:
14.
15. Give the input for Enter the temperature on C to F and F to C buttons as
shown to convert temperature and also check for exit with shortcut.
16. RESULT:
i. Thus the GUI design for temperature conversion application
has been successfully deployed.
EJB COMPONENT FOR SIMPLE AND COMPOUND INTEREST
AIM:
To develop EJB component for finding simple and compound interest
using Netbeans IDE.
PROCEDURE:
15. Now right click inside the program select Insert code->call
enterprise bean->interestSession-ejb->InterestSession and select
interface as remote click on ok.
a.
17. Change the request.getContextPath() as
ejbsession.simple(30000,3.0f,0.35f) for simple interest and copy the
same line, paste it next to it and where change the
ejbsession.simple(30000,3.0f,0.35f) as
ejbsession.compound(5000,2.0f,0.30f) for compound interest as shown
above.
OUTPUT:
RESULT:
Thus the EJB component for finding simple interest and compound
interest has been successfully executed using Netbeans IDE.
EJB COMPONENT FOR ORDER PLACING
AIM:
To develop EJB component for order placing using Netbeans IDE.
PROCEDURE:
RESULT:
Thus the EJB component for placing order and finding total cost has been
successfully executed using Netbeans IDE.
EJB COMPONENT FOR PAYMENT PROCESSING
AIM:
To develop EJB component for payment processing i.e, calculating gross
salary of an employee using Netbeans IDE.
PROCEDURE:
14. Now right click inside the program select Insert code->call
enterprise bean->saljjsession-ejb->saljjsession and select interface as
remote click on ok.
RESULT:
Thus the EJB component for finding payment processing has been
successfully executed using Netbeans IDE.
CREATING A WEB SERVICES FOR ARITHMETIC OPERATION
AIM:
To create a web services for arithmetic operation.
PROCEDURE:
package mypackj;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService()
public class arithwebj {
@WebMethod(operationName = "add")
public int add(@WebParam(name = "a")
int a, @WebParam(name = "b")
int b) {
AIM:
To create a web service and calling a web service for a addition function
using visual studio.
PROCEDURE:
2. Select file -> new -> website -> select visual c# and empty website.
4. Right click on the project additionservice -> choose add new item -> select
webservices
5. Create a addition function and add the following code:
6. Right click on the project additionservice -> choose add new item -> select
webform
7. Choose split -> select toolbox -> drag and drop the textbox, button and label
for result.
8. Add the following code:
9. Double click on the button and add the coding as follows:
10. Right click on the project additionservice -> select build website
11. Right click on the project additionservice -> select view in browser.
OUTPUT:
RESULT:
Thus the above program for creating a web service of addition using
asp.net was successfully executed and verified.
CREATING A WEB SERVICES FOR STRING OPERATION
AIM:
To create a web services application for String operation.
PROCEDURE:
OUTPUT:
stringjservice
RESULT:
Thus, the above program was successfully executed and verified.
JAXB BINDING PROGRAM
AIM:
To generate a java program by xml program using JAXB binding.
PROCEDURE:
<xsd:element name="shiporder">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="orderperson" type="xsd:string"/>
<xsd:element name="shipto">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Name" type="xsd:string"/>
<xsd:sequence>
<xsd:element name="productid" type="xsd:positiveInteger"/>
<xsd:element name="note" type="xsd:string" minOccurs="0"/>
<xsd:element name="quantity" type="xsd:positiveInteger" />
<xsd:element name="price" type="xsd:decimal" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="orderid" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>
6. Right click on the project jaax -> new file -> select others -> xml -> jaxb
binding.
7. Give the name as jaax2-> Browse for schema file jaax1-> click on finish.
8. On the project -> Right click on the JAXB bindings -> select regenerate
java code.
9. Choose generated source code -> open the package org.pack -> Open
Shiporder.java.
OUTPUT:
RESULT:
Thus, the above program was successfully execute and verified.
CREATION OF WEB SERVICE CLIENT
AIM:
To create a web service for adding few numbers using NetBeans and write
client side code to invoke the web service.
ALGORITHM:
1. Using the Netbeans API create a project of the type web application.
2. Create a web service in the project.
3. Click on the Design tab and design the prototype of the web service.
4. Click on source tab and modify the application logic of the web service.
5. Save the project.
6. Right click on the project and click on deploy and undeploy.
7. Then test the web service.
8. Create another web application project and create a jsp file.
9. Right click on project and click on create web service client.
10. Browse and choose the web service created i.ewsdlurl
11. Drag and drop the web service reference to the source code
window.
12. Then pass the appropriate parameters to the web service client and
invoke the web service.
STEPS TO CREATE CLIENT SIDE PROJECT:
1. Create the new project as above and give the name as addclient.
2. addclient project will be created right click it and choose the following.
3. Then browse and choose the addwebwsdl file
4. Then choose the following and add the source code in index.jsp and save it.
6. Click on the actionn.jsp page then right click in it and choose web service
client reference ->call web service
7. The invoke the add service.
RESULT:
Thus, the above program was successfully executed and verified.
CREATING A LOGIN PAGE USING JAVA SWING
AIM:
To create a login page using JAVA Swing in the Netbeans IDE.
PROCEDURE:
1. File→new project→java→java application→give the name of the project
and the package name→finish.
2. Right click on the project →new→JFrame form→give the frame name
→click finish.
3. From the toolbox drag and drop two labels , two textboxes and one button.
7. Database Connection:
i. Select service explorer→Database→right click→new
connection→select drivers: Oracle Thin→select Add
button→select OJDBC11.JAR file.
ii. Give the host name as localhost; port : 1521; service ID : XE;
username : System; Password : Tiger→click on Test
Connection→next→next→finish.
8. How to run :
Right click on the JFrame form(login)→select “run file”.
OUTPUT:
RESULT:
Thus, the above program was successfully executed and verified.
CREATE A WEB SERVICE USING ASP.NET
AIM:
To create a web service for addition function using ASP.NET.
PROCEDURE:
2. Right click on the project select add->new item->web service and give
name for web service as firstwebservice->add.
3. Add the web method for calculator operation as shown in the figure.
4. Right click on the project select view in browser.
5. Click on firstwebservice.asmx.
12. Now double click on the button and add the following code.(include
the header file using firstform.firstreference.)
13. Right click on the solution->properties->set start up web sites as
firstform.
OUTPUT:
14. Now click the build symbol. the following will get as ouput.
Result:
Thus the creation a web service for addition function program has been
executed and verified successfully
CREATING EMPLOYEE DETAILS USING JAVA SWING
AIM:
To create employee details using JAVA Swing in the Netbeans IDE.
PROCEDURE:
1. File→new project→java→java application→give the name of the project
and the package name→finish.
2. Right click on the project →new→JFrame form→give the frame name
→click finish.
3. From the toolbox drag and drop seven labels , six textboxes and one
button.
a.
6.
7. Database Creation:
8. Start→all programs→oracle database 10g→go to database
homepage→give the username and the password.
9. Click on the from the object browser and select create table→give the
table name→create the requiredcolumns andselect the required
datatype.
10. Click next→next→ at last click “create”.
11. Database Connection:
12. Select service explorer→Database→right click→new
connection→select drivers: Oracle Thin→select Add button→select
OJDBC11.JAR file.
13. Give the host name as localhost; port : 1521; service ID : XE;
username : System; Password : Tiger→click on Test
Connection→next→next→finish.
14. How to run :
OUTPUT:
Before inserting:
After inserting:
RESULT:
Thus, the above program was successfully executed and verified.
CREATION OF A BPEL MODULE AND A COMPOSITE APPLICATION
AIM:
To Create a SOA project with BPEL Module to compose a web service.
3. In the Name and Location page, enter the project name (for this example
HelloWorld) and specify the project location or accept the defaults.
4. Click Finish.
The Projects window now contains a project node for the BPEL Module project.
7. To save your changes click the Save All icon in the IDE menu bar.
Creating a Composite Application Project
A BPEL Module project is not directly deployable. You must first add a BPEL
Module project, as a JBI module, to a Composite Application project. You can
then deploy the Composite Application project. Deploying the project makes
the service assembly available to the application server and enables its service
units to run.
To Create a New Composite Application Project
1. Choose File > New Project (Ctrl-Shift-N).
2. In the Categories list choose Service Oriented Architecture, in the Projects
list choose Composite Application, and click Next.
3. In the Name and Location page, change the project name to
HelloWorldApplication, and specify the location of project files.
4. To set the new Composite Application the main project as main, leave the
Set as Main Project checkbox selected, and click Finish.
5. To add the BPEL Module as a JBI module to the Composite Application
project, right-click the new Composite Application and choose Add JBI
Module.
The Select Project dialog box opens.
6. Select the HelloWorld project you created earlier and click Add Project
JAR Files.
The Select Project dialog box closes and the HelloWorld.jar file is added to the
JBI Modules node of the HelloWorldApplication Composite Application
Building and Deploying the Composite Application Project
Building a project compiles the BPEL source file and packages the BPEL file and
web service artifacts, including WSDL and XSD files, into a JAR archive.
Deploying the project compiles the files in the Composite Application project,
packages the compiled BPEL and related web service artifacts (including WSDL
and XSD files) into an archive, and deploys them to the Application Server.
To Build and Deploy the Composite Application Project
1. Right-click the Composite Application project's node, and choose Build.
When the build is complete the Output window reports Build Successful. If the
Output window is not visible, choose Window -> Output -> Output.
2. Right-click the Composite Application project's node, and choose Deploy.
3. Deployment has succeeded when you see a Build successful message in
the GlassFish tab of the Output window.
4. Open the Services window and expand Servers ->GlassFish V2 -> JBI ->
Service Assemblies to see your new deployed Service Assembly.
If you do not see the deployed project, right-click the Service Assemblies node
and choose Refresh.
Testing the Composite Application
You can test your Composite Application project by adding test cases, binding
to the operation, supplying input, and then using the tester.
Test the HelloWorldApplication Composite Application Project
1. In the Projects window, expand the HelloWorldApplication project node,
right-click the Test node, and choose New Test Case.
The New Test Case wizard opens.
2. Accept the default test case name, TestCase1, and click Next.
3. From the Select the WSDL Document page, expand the HelloWorld - Proecss
Files node, select Synchronous.wsdl, and click Next.
4. From the Select the Operation to Test page, select the Operation1 and click
Finish.
A new TestCase1 node is added under the project's Test node in the Projects
window, containing two subnodes, Input and Output.
The Source Editor appears containing the Input file, Input.xml
Note –
If the Source Editor does not contain a tab for Input.xml, double-click the Input
node in the Projects window to open the file.
5. From the Input.xml tab of the Source Editor, do the following:
a. Locate the line:
<syn:paramA>?string?<syn:paramA>
b. Replace ?string? with Hello World, so that the line appears as follows:
<syn:paramA>Hello World<syn:paramA>
6. In the Projects window, double-click the Output node under Test ->
TestCase1.
Output.xml is opened in the Source Editor. Initially, Output.xml is empty until
the first test run populates the file.
7. In the Projects window, right-click the TestCase1 node and choose Run from
the pop-up menu.
When the Overwrite Empty Output dialog box appears, click Yes to accept new
output. The first test run populates the Output.xml file displayed in the Source
Editor.
The test compares the output to the contents of the output file. Because the first
run of the test has nothing to compare itself to, the first test fails. Subsequent
test runs will compare their output with the contents of Output.xml and should
succeed.
8. Run the test again.
The test case is compared to the current output file and succeeds.
RESULT:
Thus, the above program for creating a bpel module and a composite
application was successfully executed and verified.