SlideShare a Scribd company logo
T.Y.B.Sc. Computer Science Roll No.
INDEX
Practical No. Practical Name Page
No.
Date Remark Signature
1. Simple Server-Side Programming
using Servlets . Where user can
get the information about server.
01 to 03 05/12/2015
2. Advance Server-Side
Programming using Servlets.
Where user can get details of his
created table in SQL.
04 to 08 12/12/2015
3. Simple Server-side programming
using JSP for Login page where
after login the page forwarded to
new welcome page and if login
details are wrong then page
transferred to index page.
09 to 12 19/12/2015
4. Advance Server-side
programming using JSP for login
page where login details for user
taken from database created in
SQL. If user_id and password
entered by user is wrong then
page redirected to invalid page or
else redirected to Home page.
13 to 20 02/01/2016
5. Developing Simple Enterprise
Java Beans for addition of two
numbers by taking inputs from
user.
21 to 25 09/01/2016
6. Developing Advance Enterprise
Java Beans. Where user is
entering details of registration
form in Registration.jsp file and
the data entered by user should be
stored in database.
26 to 29 23/01/2016
7. Developing Simple Web services
in Java Demonstrate a simple web
service that generates a response
based on information received
from the client.
30 to 34 06/02/2016
8. Developing Advance Web
services in Java. Develop web
service for calculator applications,
to implement simple arithmetic
Operations. Use WSDL for these
web services to show output.
35 to 39 13/02/2016
T.Y.B.Sc. Computer Science Roll No.
Practical No: 1
Practical Name :–
Simple Server-Side Programming using Servlets. Where user can get the information about
server.
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="serverinfo" method="post">
<input type="submit" value="submit">
</form>
</body>
</html>
T.Y.B.Sc. Computer Science Roll No.
Serverinfo.java :-
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;
public class extends HttpServlet {
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
out.println("<html>");
out.println("<head>");
out.println("<h3>Server Info:<h3>");
out.println("Server Name:"+request.getServerName()+"<br><br>");
out.println("Server Port:"+request.getServerPort()+"<br><br>");
out.println("Client Browser:"+request.getHeader("User Agent")+"<br><br>");
out.println("Server Referer:"+request.getHeader("Referer")+"<br><br>");
out.println("Client IP:"+request.getRemoteAddr()+"<br><br>");
out.println("Server OS Version:"+System.getProperty("os.version")+"<br><br>");
out.println("</head>");
out.println("<body>");
out.println("</body>");
out.println("</html>");
} finally {
out.close();
}
}
}
T.Y.B.Sc. Computer Science Roll No.
Output :-
T.Y.B.Sc. Computer Science Roll No.
Practical No: 2
Practical Name :–
Advance Server-Side Programming using Servlets. Where user can get details of his created
table in SQL.
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="dataconnection1" method="POST">
<input type="submit" value="submit">
</form>
</body>
</html>
T.Y.B.Sc. Computer Science Roll No.
Dataconnection1.java :-
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.*;
import javax.sql.*;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet(name = "dataconnection1", urlPatterns = {"/dataconnection1"})
public class dataconnection1 extends HttpServlet implements Servlet
{
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
out.println("connectivity begins");
Connection cn;
Statement st;
ResultSet rs;
cn=DriverManager.getConnection("jdbc:odbc:ServletDSN","system","dbms");
out.println("cooncted successfully");
st=cn.createStatement();
st.executeUpdate("create table Aut1(AuId Number,AuName Char(15),AuAddr
Char(30))");
out.println("Table Created");
st.executeUpdate("insert into Aut1 values(1,'ABC','Panvel')");
st.executeUpdate("insert into Aut1 values(2,'XYZ','Pune')");
out.println("Records inserted into table");
rs=st.executeQuery("select * from Aut1");
out.println("AuId &nbsp &nbsp AuName &nbsp &nbsp AuAddr <br>");
T.Y.B.Sc. Computer Science Roll No.
while(rs.next())
{
out.println(rs.getInt(1)+"&nbsp &nbsp &nbsp");
out.println(rs.getString(2)+"&nbsp &nbsp &nbsp");
out.println(rs.getString(3)+"&nbsp &nbsp &nbsp");
st.close(); }
rs.close();
cn.close();
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet dataconnection1</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet dataconnection1 at " + request.getContextPath() + "</h1>");
out.println("</body>");
out.println("</html>");
}
catch(Exception e1)
{
System.out.println("Failed");
}
finally {
out.close();
}
}
}
T.Y.B.Sc. Computer Science Roll No.
Output:-
T.Y.B.Sc. Computer Science Roll No.
T.Y.B.Sc. Computer Science Roll No.
Practical No: 3
Practical Name:–
Simple Server-side programming using JSP for Login page where after login the page forwarded
to new welcome page and if login details are wrong then page transferred to index page.
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 method="post" action="login1.jsp">
username<input type="text" name="txtname" size="20"><br>
password<input type="password" name="pwd" size="20"><br>
<input type="submit" value="Login">
</form>
</body>
</html>
T.Y.B.Sc. Computer Science Roll No.
Login1.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>
<%if((request.getParameter("txtname").equals("yogita"))&&(request.getParameter("pwd").equal
s("vyom"))){%>
<jsp:forward page="welcome.jsp"></jsp:forward>
<%} else{ out.println("Enter correct details");%>
<jsp:include page="index.jsp"></jsp:include>
<%}%>
</body>
</html>
T.Y.B.Sc. Computer Science Roll No.
Login1.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>
<h1>Hello World!</h1>
</body>
</html>
T.Y.B.Sc. Computer Science Roll No.
Output:-
T.Y.B.Sc. Computer Science Roll No.
T.Y.B.Sc. Computer Science Roll No.
Practical No: 4
Practical Name:–
Advance Server-side programming using JSP for login page where login details for user taken
from database created in SQL. If user_id and password entered by user is wrong then page
redirected to invalid page or else redirected to Home page.
Index.jsp :-
<%--
Document : index
Created on : Mar 8, 2016, 10:54:04 AM
Author : computerlab
--%>
<%@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="TLogin.jsp" method="post">
<table bgcolor="yellow">
<tr><td>User Name:<input type="text" name="userid" size="15"></td></tr>
<tr><td>Password:<input type="password" name="pwd" size="15"></td></tr>
<tr><td colspan="2" align="center"><input type="submit" name="submit"
size="10"></td></tr>
</table>
</form>
</body>
</html>
T.Y.B.Sc. Computer Science Roll No.
TLogin.jsp :-
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<%@page import="javax.sql.*"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
Connection con;
String userid=request.getParameter("userid");
out.println("hellow"+userid);
session.setAttribute("userid",userid);
String pwd=request.getParameter("pwd");
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/student","root","root");
out.println("connected successfully");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from student where userid='"+userid+"'");
if(rs.next())
{
if(rs.getString(2).equals(pwd))
{
//System.out.println("Login sucessfully");
response.sendRedirect("Home.jsp");
}
else
{
response.sendRedirect("Invalid.jsp");
}
}
%>
</body>
</html>
T.Y.B.Sc. Computer Science Roll No.
Invalid.jsp :-
<%--
Document : Invalid
Created on : Mar 8, 2016, 10:56:04 AM
Author : computerlab
--%>
<%@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>
<body bgcolor="pink">
<h1>Invalid User ID or Password<%=session.getAttribute("userid")%>!!!</h1>
</body>
</html>
T.Y.B.Sc. Computer Science Roll No.
Home.jsp :-
<%--
Document : Home
Created on : Feb 23, 2016, 9:06:59 AM
Author : computerlab
--%>
<%@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>
<body bgcolor="pink">
<h1>Welcome<%=session.getAttribute("userid")%>!!!</h1>
</body>
</html>
T.Y.B.Sc. Computer Science Roll No.
Output:-
T.Y.B.Sc. Computer Science Roll No.
T.Y.B.Sc. Computer Science Roll No.
T.Y.B.Sc. Computer Science Roll No.
T.Y.B.Sc. Computer Science Roll No.
Practical No: 5
Practical Name:–
Developing Simple Enterprise Java Beans for addition of two numbers by taking inputs from
user.
Index.jsp :-
<%--
Document : index
Created on : Feb 12, 2016, 9:08:58 AM
Author : computelab
--%>
<%@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 method="post" action="calcservlet">
<input type="text" name="t1">
<input type="text" name="t2">
<input type="submit" value="OK">
</form>
</body>
</html>
T.Y.B.Sc. Computer Science Roll No.
calcservlet.java :-
import ejb.calbeanLocal;
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;
public class calcservlet extends HttpServlet {
calbeanLocal calbean=new calbeanLocal();
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet calcservlet</title>");
out.println("</head>");
out.println("<body>");
int a=Integer.parseInt(request.getParameter("t1"));
int b=Integer.parseInt(request.getParameter("t2"));
out.println("<h1>Sum ="+calbean.addition(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.">
/**
* Handles the HTTP
* <code>GET</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
T.Y.B.Sc. Computer Science Roll No.
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP
* <code>POST</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
T.Y.B.Sc. Computer Science Roll No.
calbeanLocal.java :-
package ejb;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
@Stateless
@LocalBean
public class calbeanLocal {
public Integer addition(int a, int b) {
return (a+b);
}
}
T.Y.B.Sc. Computer Science Roll No.
Output:-
T.Y.B.Sc. Computer Science Roll No.
Practical No: 6
Practical Name:–
Developing Advance Enterprise Java Beans. Where user is entering details of registration form
in Registration.jsp file and the data entered by user should be stored in database.
Index.jsp:
<%--
Document : index
Created on : Mar 2, 2016, 12:10:46 PM
Author : computerlab
--%>
<%@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="Registeration1.jsp" method="post">
User Name: <input type="text" name="un"><br/>
Password: <input type="text" name="tp"><br/>
First Name: <input type="text" name="fn"><br/>
Last Name: <input type="text" name="ln"><br/>
Email: <input type="text" name="e"><br/>
<input type="submit" value="Register"><br/>
</form>
</body>
</html>
<%--
T.Y.B.Sc. Computer Science Roll No.
Registeration1.jsp:-
Created on : Aug 31, 2015, 9:41:20 AM
Author : computerlab
--%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.PreparedStatement"%>
<%@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">
<title>JSP Page</title>
</head>
<body>
<%
String user_name=request.getParameter("un");
String pswd=request.getParameter("tp");
String first_name=request.getParameter("fn");
String last_name=request.getParameter("ln");
String email=request.getParameter("e");
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/reg1","root","root");
PreparedStatement ps = con.prepareStatement("insert into new_table values(?,?,?,?,?)");
ps.setString(1, user_name);
ps.setString(2, pswd);
ps.setString(3, first_name);
ps.setString(4, last_name);
ps.setString(5, email);
ps.executeUpdate();
out.println("Successful Registration");
}
catch(Exception e)
{
out.println("Exception caught"+e);
}
%>
</body>
</html>
T.Y.B.Sc. Computer Science Roll No.
Output:-
T.Y.B.Sc. Computer Science Roll No.
T.Y.B.Sc. Computer Science Roll No.
Practical No: 7
Practical Name:–
Developing Simple Web services in Java
Demonstrate a simple web service that generates a response based on information received from
the client.
T.Y.B.Sc. Computer Science Roll No.
T.Y.B.Sc. Computer Science Roll No.
Program :-
package server;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService()
public class HelloWebService
{
@WebMethod(operationName = "sayHello")
public String sayHello(@WebParam(name = "name")String name)
{
return "Hello -" + name;
}
}
T.Y.B.Sc. Computer Science Roll No.
T.Y.B.Sc. Computer Science Roll No.
T.Y.B.Sc. Computer Science Roll No.
Practical No: 8
Practical Name:–
Developing Advance Web services in Java.
Develop web service for calculator applications, to implement simple arithmetic
Operations. Use WSDL for these web services to show output.
T.Y.B.Sc. Computer Science Roll No.
T.Y.B.Sc. Computer Science Roll No.
Program :-
package server;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService()
public class CalcWebService
{
@WebMethod(operationName = "add")
public int add(
@WebParam(name = "i")int i,
@WebParam(name = "j")int j)
{
return i+j;
}
}
T.Y.B.Sc. Computer Science Roll No.
T.Y.B.Sc. Computer Science Roll No.

More Related Content

DOCX
ANGULAR JS LAB MANUAL(final) vtu2021 sch
PDF
JavaScript - Chapter 13 - Browser Object Model(BOM)
PPTX
Polymorphism and its types
KEY
HTML CSS & Javascript
PPTX
Bootstrap Web Development Framework
PPTX
Java Script An Introduction By HWA
PPTX
HTML (Web) basics for a beginner
ANGULAR JS LAB MANUAL(final) vtu2021 sch
JavaScript - Chapter 13 - Browser Object Model(BOM)
Polymorphism and its types
HTML CSS & Javascript
Bootstrap Web Development Framework
Java Script An Introduction By HWA
HTML (Web) basics for a beginner

What's hot (20)

PPT
On-line book store presentation
PPTX
Asp.NET Validation controls
DOC
Project report
PPTX
Identifiers
PDF
Html for beginners
PPT
Css Ppt
PDF
2. HTML forms
PPTX
Bootstrap 3
PPTX
Operators in Python
PDF
3. Java Script
DOCX
Software requirement specification
PDF
Introduction to html
PPTX
Html form tag
PPT
Html presentation
PDF
CSS Notes in PDF, Easy to understand. For beginner to advanced. ...
PDF
Book management system
PPT
Bank management system with java
PPTX
html5.ppt
PPTX
JavaScript Basic
KEY
HTML presentation for beginners
On-line book store presentation
Asp.NET Validation controls
Project report
Identifiers
Html for beginners
Css Ppt
2. HTML forms
Bootstrap 3
Operators in Python
3. Java Script
Software requirement specification
Introduction to html
Html form tag
Html presentation
CSS Notes in PDF, Easy to understand. For beginner to advanced. ...
Book management system
Bank management system with java
html5.ppt
JavaScript Basic
HTML presentation for beginners
Ad

Viewers also liked (20)

DOC
Ad java prac sol set
PDF
Advanced Java Practical File
DOC
Advanced Java - Praticals
PDF
Java programming-examples
DOCX
Java codes
DOCX
Core java tutorial
PDF
Linux practicals T.Y.B.ScIT
DOCX
Data Warehousing Practical for T.Y.I.T.
DOCX
Java PRACTICAL file
DOCX
Java Code for Sample Projects Inheritance
DOCX
Unit 1st and 3rd notes of java
DOC
collisiondetection
PDF
Forouzan appendix
DOCX
Htmlcolorcodes 150323101937-conversion-gate01
DOCX
Java unit 4_cs_notes
DOCX
J2 ee tutorial ejb
DOCX
Definition
DOCX
Html color codes
DOCX
Embedded System Practical manual (1)
PDF
Java lab-manual
Ad java prac sol set
Advanced Java Practical File
Advanced Java - Praticals
Java programming-examples
Java codes
Core java tutorial
Linux practicals T.Y.B.ScIT
Data Warehousing Practical for T.Y.I.T.
Java PRACTICAL file
Java Code for Sample Projects Inheritance
Unit 1st and 3rd notes of java
collisiondetection
Forouzan appendix
Htmlcolorcodes 150323101937-conversion-gate01
Java unit 4_cs_notes
J2 ee tutorial ejb
Definition
Html color codes
Embedded System Practical manual (1)
Java lab-manual
Ad

Similar to Advanced java practical semester 6_computer science (20)

PPTX
Understanding JSP -Servlets
PPTX
JavaServer Pages
PDF
Experiences on a Design Approach for Interactive Web Applications
PDF
PDF
Java(Java_Servlet_programs_examples).pdf
PDF
Penetration Testing with Improved Input Vector Identification
PPTX
Cis 274 intro
PPTX
Web Technologies - forms and actions
PPTX
Sessionex1
PDF
TYCS Visual Basic Practicals
PPT
presentation on java server pages vs servlet.ppt
DOCX
การเข ยนโปรแกรมต ดต_อฐานข_อม_ล
PDF
Servlets intro
PPT
Presentation
PPTX
Java web application development
PPTX
JSP APP DEVLOPMENT.pptx Related to Android App Development
PPTX
6 weeks 6 months live project summer industrial training in cmc limited 2012
PDF
Web Development With Java Using Hibernate Jsps And Servlets Tim Downey
PPTX
Request dispacther interface ppt
Understanding JSP -Servlets
JavaServer Pages
Experiences on a Design Approach for Interactive Web Applications
Java(Java_Servlet_programs_examples).pdf
Penetration Testing with Improved Input Vector Identification
Cis 274 intro
Web Technologies - forms and actions
Sessionex1
TYCS Visual Basic Practicals
presentation on java server pages vs servlet.ppt
การเข ยนโปรแกรมต ดต_อฐานข_อม_ล
Servlets intro
Presentation
Java web application development
JSP APP DEVLOPMENT.pptx Related to Android App Development
6 weeks 6 months live project summer industrial training in cmc limited 2012
Web Development With Java Using Hibernate Jsps And Servlets Tim Downey
Request dispacther interface ppt

More from Niraj Bharambe (8)

PDF
Tybsc cs dbms2 notes
PDF
DCN Practical
PDF
T.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai University
PDF
Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.
PDF
Core java pract_sem iii
DOCX
Xml 150323102007-conversion-gate01
DOCX
Htmlnotes 150323102005-conversion-gate01
PDF
Sixth sense technology
Tybsc cs dbms2 notes
DCN Practical
T.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai University
Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.
Core java pract_sem iii
Xml 150323102007-conversion-gate01
Htmlnotes 150323102005-conversion-gate01
Sixth sense technology

Recently uploaded (20)

PPTX
Pharma ospi slides which help in ospi learning
PDF
RMMM.pdf make it easy to upload and study
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Institutional Correction lecture only . . .
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Cell Structure & Organelles in detailed.
Pharma ospi slides which help in ospi learning
RMMM.pdf make it easy to upload and study
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
human mycosis Human fungal infections are called human mycosis..pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
O7-L3 Supply Chain Operations - ICLT Program
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
A systematic review of self-coping strategies used by university students to ...
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Institutional Correction lecture only . . .
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Supply Chain Operations Speaking Notes -ICLT Program
Module 4: Burden of Disease Tutorial Slides S2 2025
Cell Structure & Organelles in detailed.

Advanced java practical semester 6_computer science

  • 1. T.Y.B.Sc. Computer Science Roll No. INDEX Practical No. Practical Name Page No. Date Remark Signature 1. Simple Server-Side Programming using Servlets . Where user can get the information about server. 01 to 03 05/12/2015 2. Advance Server-Side Programming using Servlets. Where user can get details of his created table in SQL. 04 to 08 12/12/2015 3. Simple Server-side programming using JSP for Login page where after login the page forwarded to new welcome page and if login details are wrong then page transferred to index page. 09 to 12 19/12/2015 4. Advance Server-side programming using JSP for login page where login details for user taken from database created in SQL. If user_id and password entered by user is wrong then page redirected to invalid page or else redirected to Home page. 13 to 20 02/01/2016 5. Developing Simple Enterprise Java Beans for addition of two numbers by taking inputs from user. 21 to 25 09/01/2016 6. Developing Advance Enterprise Java Beans. Where user is entering details of registration form in Registration.jsp file and the data entered by user should be stored in database. 26 to 29 23/01/2016 7. Developing Simple Web services in Java Demonstrate a simple web service that generates a response based on information received from the client. 30 to 34 06/02/2016 8. Developing Advance Web services in Java. Develop web service for calculator applications, to implement simple arithmetic Operations. Use WSDL for these web services to show output. 35 to 39 13/02/2016
  • 2. T.Y.B.Sc. Computer Science Roll No. Practical No: 1 Practical Name :– Simple Server-Side Programming using Servlets. Where user can get the information about server. 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="serverinfo" method="post"> <input type="submit" value="submit"> </form> </body> </html>
  • 3. T.Y.B.Sc. Computer Science Roll No. Serverinfo.java :- 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; public class extends HttpServlet { protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { out.println("<html>"); out.println("<head>"); out.println("<h3>Server Info:<h3>"); out.println("Server Name:"+request.getServerName()+"<br><br>"); out.println("Server Port:"+request.getServerPort()+"<br><br>"); out.println("Client Browser:"+request.getHeader("User Agent")+"<br><br>"); out.println("Server Referer:"+request.getHeader("Referer")+"<br><br>"); out.println("Client IP:"+request.getRemoteAddr()+"<br><br>"); out.println("Server OS Version:"+System.getProperty("os.version")+"<br><br>"); out.println("</head>"); out.println("<body>"); out.println("</body>"); out.println("</html>"); } finally { out.close(); } } }
  • 4. T.Y.B.Sc. Computer Science Roll No. Output :-
  • 5. T.Y.B.Sc. Computer Science Roll No. Practical No: 2 Practical Name :– Advance Server-Side Programming using Servlets. Where user can get details of his created table in SQL. 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="dataconnection1" method="POST"> <input type="submit" value="submit"> </form> </body> </html>
  • 6. T.Y.B.Sc. Computer Science Roll No. Dataconnection1.java :- import java.io.IOException; import java.io.PrintWriter; import java.sql.*; import javax.sql.*; import javax.servlet.Servlet; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet(name = "dataconnection1", urlPatterns = {"/dataconnection1"}) public class dataconnection1 extends HttpServlet implements Servlet { protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); out.println("connectivity begins"); Connection cn; Statement st; ResultSet rs; cn=DriverManager.getConnection("jdbc:odbc:ServletDSN","system","dbms"); out.println("cooncted successfully"); st=cn.createStatement(); st.executeUpdate("create table Aut1(AuId Number,AuName Char(15),AuAddr Char(30))"); out.println("Table Created"); st.executeUpdate("insert into Aut1 values(1,'ABC','Panvel')"); st.executeUpdate("insert into Aut1 values(2,'XYZ','Pune')"); out.println("Records inserted into table"); rs=st.executeQuery("select * from Aut1"); out.println("AuId &nbsp &nbsp AuName &nbsp &nbsp AuAddr <br>");
  • 7. T.Y.B.Sc. Computer Science Roll No. while(rs.next()) { out.println(rs.getInt(1)+"&nbsp &nbsp &nbsp"); out.println(rs.getString(2)+"&nbsp &nbsp &nbsp"); out.println(rs.getString(3)+"&nbsp &nbsp &nbsp"); st.close(); } rs.close(); cn.close(); out.println("<html>"); out.println("<head>"); out.println("<title>Servlet dataconnection1</title>"); out.println("</head>"); out.println("<body>"); out.println("<h1>Servlet dataconnection1 at " + request.getContextPath() + "</h1>"); out.println("</body>"); out.println("</html>"); } catch(Exception e1) { System.out.println("Failed"); } finally { out.close(); } } }
  • 8. T.Y.B.Sc. Computer Science Roll No. Output:-
  • 10. T.Y.B.Sc. Computer Science Roll No. Practical No: 3 Practical Name:– Simple Server-side programming using JSP for Login page where after login the page forwarded to new welcome page and if login details are wrong then page transferred to index page. 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 method="post" action="login1.jsp"> username<input type="text" name="txtname" size="20"><br> password<input type="password" name="pwd" size="20"><br> <input type="submit" value="Login"> </form> </body> </html>
  • 11. T.Y.B.Sc. Computer Science Roll No. Login1.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> <%if((request.getParameter("txtname").equals("yogita"))&&(request.getParameter("pwd").equal s("vyom"))){%> <jsp:forward page="welcome.jsp"></jsp:forward> <%} else{ out.println("Enter correct details");%> <jsp:include page="index.jsp"></jsp:include> <%}%> </body> </html>
  • 12. T.Y.B.Sc. Computer Science Roll No. Login1.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> <h1>Hello World!</h1> </body> </html>
  • 13. T.Y.B.Sc. Computer Science Roll No. Output:-
  • 15. T.Y.B.Sc. Computer Science Roll No. Practical No: 4 Practical Name:– Advance Server-side programming using JSP for login page where login details for user taken from database created in SQL. If user_id and password entered by user is wrong then page redirected to invalid page or else redirected to Home page. Index.jsp :- <%-- Document : index Created on : Mar 8, 2016, 10:54:04 AM Author : computerlab --%> <%@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="TLogin.jsp" method="post"> <table bgcolor="yellow"> <tr><td>User Name:<input type="text" name="userid" size="15"></td></tr> <tr><td>Password:<input type="password" name="pwd" size="15"></td></tr> <tr><td colspan="2" align="center"><input type="submit" name="submit" size="10"></td></tr> </table> </form> </body> </html>
  • 16. T.Y.B.Sc. Computer Science Roll No. TLogin.jsp :- <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page import="java.sql.*"%> <%@page import="javax.sql.*"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <% Connection con; String userid=request.getParameter("userid"); out.println("hellow"+userid); session.setAttribute("userid",userid); String pwd=request.getParameter("pwd"); Class.forName("com.mysql.jdbc.Driver"); con=DriverManager.getConnection("jdbc:mysql://localhost:3306/student","root","root"); out.println("connected successfully"); Statement st=con.createStatement(); ResultSet rs=st.executeQuery("select * from student where userid='"+userid+"'"); if(rs.next()) { if(rs.getString(2).equals(pwd)) { //System.out.println("Login sucessfully"); response.sendRedirect("Home.jsp"); } else { response.sendRedirect("Invalid.jsp"); } } %> </body> </html>
  • 17. T.Y.B.Sc. Computer Science Roll No. Invalid.jsp :- <%-- Document : Invalid Created on : Mar 8, 2016, 10:56:04 AM Author : computerlab --%> <%@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> <body bgcolor="pink"> <h1>Invalid User ID or Password<%=session.getAttribute("userid")%>!!!</h1> </body> </html>
  • 18. T.Y.B.Sc. Computer Science Roll No. Home.jsp :- <%-- Document : Home Created on : Feb 23, 2016, 9:06:59 AM Author : computerlab --%> <%@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> <body bgcolor="pink"> <h1>Welcome<%=session.getAttribute("userid")%>!!!</h1> </body> </html>
  • 19. T.Y.B.Sc. Computer Science Roll No. Output:-
  • 23. T.Y.B.Sc. Computer Science Roll No. Practical No: 5 Practical Name:– Developing Simple Enterprise Java Beans for addition of two numbers by taking inputs from user. Index.jsp :- <%-- Document : index Created on : Feb 12, 2016, 9:08:58 AM Author : computelab --%> <%@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 method="post" action="calcservlet"> <input type="text" name="t1"> <input type="text" name="t2"> <input type="submit" value="OK"> </form> </body> </html>
  • 24. T.Y.B.Sc. Computer Science Roll No. calcservlet.java :- import ejb.calbeanLocal; 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; public class calcservlet extends HttpServlet { calbeanLocal calbean=new calbeanLocal(); protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { out.println("<html>"); out.println("<head>"); out.println("<title>Servlet calcservlet</title>"); out.println("</head>"); out.println("<body>"); int a=Integer.parseInt(request.getParameter("t1")); int b=Integer.parseInt(request.getParameter("t2")); out.println("<h1>Sum ="+calbean.addition(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."> /** * Handles the HTTP * <code>GET</code> method. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs
  • 25. T.Y.B.Sc. Computer Science Roll No. * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Handles the HTTP * <code>POST</code> method. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Returns a short description of the servlet. * * @return a String containing servlet description */ @Override public String getServletInfo() { return "Short description"; }// </editor-fold> }
  • 26. T.Y.B.Sc. Computer Science Roll No. calbeanLocal.java :- package ejb; import javax.ejb.LocalBean; import javax.ejb.Stateless; @Stateless @LocalBean public class calbeanLocal { public Integer addition(int a, int b) { return (a+b); } }
  • 27. T.Y.B.Sc. Computer Science Roll No. Output:-
  • 28. T.Y.B.Sc. Computer Science Roll No. Practical No: 6 Practical Name:– Developing Advance Enterprise Java Beans. Where user is entering details of registration form in Registration.jsp file and the data entered by user should be stored in database. Index.jsp: <%-- Document : index Created on : Mar 2, 2016, 12:10:46 PM Author : computerlab --%> <%@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="Registeration1.jsp" method="post"> User Name: <input type="text" name="un"><br/> Password: <input type="text" name="tp"><br/> First Name: <input type="text" name="fn"><br/> Last Name: <input type="text" name="ln"><br/> Email: <input type="text" name="e"><br/> <input type="submit" value="Register"><br/> </form> </body> </html> <%--
  • 29. T.Y.B.Sc. Computer Science Roll No. Registeration1.jsp:- Created on : Aug 31, 2015, 9:41:20 AM Author : computerlab --%> <%@page import="java.sql.DriverManager"%> <%@page import="java.sql.Connection"%> <%@page import="java.sql.PreparedStatement"%> <%@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"> <title>JSP Page</title> </head> <body> <% String user_name=request.getParameter("un"); String pswd=request.getParameter("tp"); String first_name=request.getParameter("fn"); String last_name=request.getParameter("ln"); String email=request.getParameter("e"); try { Class.forName("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/reg1","root","root"); PreparedStatement ps = con.prepareStatement("insert into new_table values(?,?,?,?,?)"); ps.setString(1, user_name); ps.setString(2, pswd); ps.setString(3, first_name); ps.setString(4, last_name); ps.setString(5, email); ps.executeUpdate(); out.println("Successful Registration"); } catch(Exception e) { out.println("Exception caught"+e); } %> </body> </html>
  • 30. T.Y.B.Sc. Computer Science Roll No. Output:-
  • 32. T.Y.B.Sc. Computer Science Roll No. Practical No: 7 Practical Name:– Developing Simple Web services in Java Demonstrate a simple web service that generates a response based on information received from the client.
  • 34. T.Y.B.Sc. Computer Science Roll No. Program :- package server; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebService; @WebService() public class HelloWebService { @WebMethod(operationName = "sayHello") public String sayHello(@WebParam(name = "name")String name) { return "Hello -" + name; } }
  • 37. T.Y.B.Sc. Computer Science Roll No. Practical No: 8 Practical Name:– Developing Advance Web services in Java. Develop web service for calculator applications, to implement simple arithmetic Operations. Use WSDL for these web services to show output.
  • 39. T.Y.B.Sc. Computer Science Roll No. Program :- package server; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebService; @WebService() public class CalcWebService { @WebMethod(operationName = "add") public int add( @WebParam(name = "i")int i, @WebParam(name = "j")int j) { return i+j; } }