Beruflich Dokumente
Kultur Dokumente
AIM: Create a web service that gives – (i) NSE Index, (ii) BSE Index, (iii) Gold Rate. The values are
stored in database. Also create a web client for a share trading firm that displays these values on
its home page.
package MyPackage;
import java.sql.*;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService()
Connection con;
Statement st;
ResultSet rs;
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:practical");
st=con.createStatement();
rs=st.executeQuery("Select*from Table_Rate");
rs.next();
1|Page
catch(Exception e){}
@WebMethod(operationName = "NSE_Index")
openConnection();
return rs.getString(1).toString();
@WebMethod(operationName = "BSE_Index")
openConnection();
return rs.getString(2).toString();
@WebMethod(operationName = "GOLD_Rate")
openConnection();
return rs.getString(3).toString();
2|Page
WEB SERVICE TEST OUTPUT: -
3|Page
openConnection Output: -
4|Page
NSE_Index Output: -
5|Page
BSE_Index Output: -
6|Page
GOLD_Rate Output: -
7|Page
APPLICATION PROJECT NAME: - MyClientApplication
<%
try {
out.println("NSE_Index = "+result);
%>
<%
try {
out.println("BSE_Index = "+result);
%>
<%
try {
out.println("Gold_Rate = "+result);
8|Page
} catch (Exception ex) {
%>
TABLE: -
OUTPUT: -
9|Page
PRACTICAL -2
AIM: Create a web service for UGC that contains a method which accepts college name as
parameter and returns the NAAC rating. The college names and their ratings are stored in
database. Design a web client to test the above web service.
package MyPackage;
import java.sql.*;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService()
Connection con;
Statement st;
ResultSet rs;
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:practical");
st=con.createStatement();
rs=st.executeQuery("Select*from Table_NAAC");
10 | P a g e
rs.next();
catch(Exception e){}
@WebMethod(operationName = "get_NAAC")
openConnection();
return rs.getString(2).toString();
11 | P a g e
openConnection OUTPUT: -
12 | P a g e
get_NAAC OUTPUT: -
13 | P a g e
APPLICATION PROJECT NAME: - UGC_NAAC APPLICATION
<%
try {
out.println("NAAC = "+result);
%>
TABLE: -
OUTPUT: -
14 | P a g e
PRACTICAL -3
AIM: Create a web service which accepts the no. from user and find its factorial.
package MyPackage;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService()
int fact=1;
@WebMethod(operationName = "fact1")
fact=fact*y;
15 | P a g e
16 | P a g e
JSP FILE: - Index.jsp
Code: -
<%
try {
int x = 0;
out.println("Result = "+result);
%>
OUTPUT: -
17 | P a g e