Savitribai Phule Pune University T.Y.B.B.A.(C.A.) Advanced Java Practical Slip 4 Answers

 


Q.1. Advanced Java:

A) Write a Java Program to delete details of students whose initial character of their

name is ‘S’.

Answer :

import java.sql.*;

 

class Slip4A {

    public static void main(String args[]) throws Exception {

        Connection con;

        Statement stmt;

 

        Class.forName("com.mysql.jdbc.Driver");

 

        con = DriverManager.getConnection("jdbc:mysql://localhost:3306/bcadb", "root", "");

        stmt = con.createStatement();

        int n = stmt.executeUpdate("delete from student where sname like 'S%'");

 

        System.out.println(n + " rows deleted..");

 

        con.close();

 

    }

}

 

B) Write a SERVLET program that provides information about a HTTP request from a

client, such as IP address and browser type. The servlet also provides information about

the server on which the servlet is running, such as the operating system type, and the

names of currently loaded servlets.

Answer :

import java.io.*;

import javax.servlet.*;

import javax.servlet.http.*;

 

public class Slip4B extends HttpServlet implements Servlet {

 

    public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {

        res.setContentType("html/text");

        PrintWriter pw = res.getWriter();

        pw.println("<html><body><h1><b>INFORMATION OF SERVER</b></h1>");

        pw.println("<br>Server Name:" + req.getServerName());

        pw.println("<br>Server Port:" + req.getServerPort());

        pw.println("<br> Ip Address:" + req.getRemoteAddr());

        pw.println("<br> CLient Browser:" + req.getHeader("User-Agent"));

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

        pw.close();

    }

}

Savitribai Phule Pune University T.Y.B.B.A.(C.A.) Advanced Java Practical Slip 4 Answers Savitribai Phule Pune University T.Y.B.B.A.(C.A.) Advanced Java Practical Slip 4 Answers Reviewed by technical_saurabh on September 21, 2022 Rating: 5

No comments:

Powered by Blogger.