JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD B.Tech III WEB TECHNOLOGIES Previous Question Paper (February/March - 2022 - R16)
Answer any five questions
All questions carry equal marks
Main
List and explain different file handling operations in PHP.
Answer
PHP provides a comprehensive set of built-in functions to perform file handling operations, allowing developers to create, read, write, append, and delete files on the server. The primary operations are as follows:
- Opening a File (fopen): The
fopen()function is used to open a file or URL. It requires two parameters: the filename and the mode (e.g., 'r' for read-only, 'w' for write-only, 'a' for append). It returns a file pointer resource on success or false on failure. - Reading a File: Several functions exist for reading content.
fread()reads a specified number of bytes from an open file.fgets()reads a single line, whilefgetc()reads a single character.file_get_contents()is a convenient function that reads the entire file into a string without needing to manually open or close it. - Writing to a File: The
fwrite()function is used to write data to an open file stream. It takes the file pointer and the string to be written as arguments. Alternatively,file_put_contents()can be used to write data to a file in a single operation, which automatically handles opening and closing the file. - Closing a File: The
fclose()function is essential to release the system resources associated with an open file pointer. It is best practice to close files immediately after operations are completed. - File Checking and Deletion: PHP provides utility functions like
file_exists()to verify if a file exists,filesize()to determine the file size, andunlink()to delete a file from the server filesystem. - File Locking: To prevent data corruption during concurrent write operations,
flock()is used to set an advisory lock on the file, ensuring that only one process can modify the file at a time.
Explain the process of reading data from web form.
Answer
Reading data from a web form involves capturing user input submitted via an HTML form using the HTTP GET or POST methods. When the form is submitted, the data is sent to the server-side script specified in the form's action attribute. In PHP, this data is accessed through the superglobal arrays $_GET or $_POST, where the keys correspond to the 'name' attributes of the form input elements.
- The HTML form must define the method (GET or POST) and the action (the target script).
- The server script receives the request and parses the key-value pairs from the HTTP request body or URL parameters.
- The script retrieves specific values using the syntax $value = $_POST['input_name'];
- It is essential to sanitize and validate this input to prevent security vulnerabilities like SQL injection or Cross-Site Scripting (XSS).
Define directories? How to list directories using PHP?
Answer
Sign in to view the complete answer paper.
Briefly explain about parsing XML in detail.
Answer
Sign in to view the complete answer paper.
Write a short note on XML DTD.
Answer
Sign in to view the complete answer paper.
What is XHTML? Explain the XHTML.
Answer
Sign in to view the complete answer paper.
Describe how an HTTP servlet handles its client request.
Answer
Sign in to view the complete answer paper.
How can you invoke other web resources such as servlets /JSPs?
Answer
Sign in to view the complete answer paper.
Define environment variables. Name and discuss any two CGI environment variables.
Answer
Sign in to view the complete answer paper.
Explain the benefits of using JavaBeans to separate business logic from presentation markup within the JSP environment.
Answer
Sign in to view the complete answer paper.
Explain about Document Object Model in JavaScript in detail.
Answer
Sign in to view the complete answer paper.