java(aim, algorithm) (1)
java(aim, algorithm) (1)
AIM:
ALGORITHM:
_____________________________________
2. AIM:
Write a program to design purchase order from HTML form and Servlet.
ALGORITHM:
_____________________________________
3. AIM:
Develop a program for calculating the percentage of marks of a student using JSP.
ALGORITHM:
Step 1: Start the program.
Step 2: Create an HTML form (Index.html) for entering student details and marks.
- Input fields for register number, name, and marks in three subjects.
- Submit button to send data to the JSP page.
Step 3: Create a JSP page (Marks.jsp) to process the form data &display the mark list.
Step 5: Retrieve parameters from the form: register, name, and subject marks.
Step 6: If any subject mark is less than 40:
Step 7: Display "Not To Evaluate" for total marks, percentage, and grade.
Step 8: If all subject marks are 40 or above:
- Calculate total marks, percentage, and determine grade.
Step 9: Display student's register number, name, total marks, and grade.
Step 10: End the program.
_____________________________________
4. AIM:
ALGORITHM:
Step 1: Start the program.
Step 2: Create an HTML form for users to input purchase details:
- Display a heading "PURCHASE ORDER FORM".
- Include input fields for name, product id, product name (pizza), quantity.
- Provide Submit and Clear buttons.
Step 3: Create a JSP page to process the form data display purchase details:
Step 4: Retrieve form data: name, product id, product name (pizza), quantity.
Step 5: Calculate the price for the selected pizza and drink based on the provided.
Step 6: Display the purchase details including name, product name, product price.
Step 7: End the program.
____________________________________
5. AIM:
ALGORITHM:
Step 1: Start the program.
Step 2: Create an HTML form for users to input employee salary details:
- Display a heading "Employee Salary Statement".
- Include input fields for employee name, department, basic salary, TA(%).
- Provide Submit and Reset buttons.
Step 3: Create a JSP page to process the form data and display the salary statement:
Step 4: Retrieve form data: employee name, department, basic salary, TA(%).
Step 5: Calculate TA, DA, HRA, PF, and LIC amounts based on the provided.
- Calculate gross salary as the sum of basic salary and allowance.
-Calculate net salary as the difference between gross salary and deduction.
- Display the salary statement including employee name, department.
Step 4: End the program.
_____________________________________
6. AIM:
Write a program using JDBC for creating a table,Inserting and listout the records.
ALGORITHM:
Step 1: Start the program.
Step 2: Create a Database class:
- Inside the main method:
- Instantiate an object of the abc class.
Step 3: Create an abc class:
Step 3.1: Inside the main method:
- Establish a connection to the database using JDBC.
- Prepare an SQL statement to insert data into the "login" table.
- Set values for the parameters in the SQL statement.
- Execute the SQL statement to insert data into the database.
Step 4 : If the execution is successful:
- Print "Row updated successfully".
Step 5 : End the program.
_____________________________________
7. AIM:
ALGORITHM:
_____________________________________
8. AIM:
Write a simple servlet program to create a table of all the headers it receives along with their
associated values.
ALGORITHM:
Step 1: Start the program.
Step 2: Define a servlet named "table" that handles HTTP requests.
Step 3: Handle HTTP GET requests:
a. Set the response content type to HTML.
b. Create an HTML document structure with a title and header.
c. Retrieve all header names from the request.
d. Close the HTML table and body.
step 4: Handle HTTP POST requests:
- Call the doGet method to handle POST requests.
Step 5: Configure the servlet in the web.xml file:
a. Map the servlet name "display1" to the servlet class "display1".
b. Map the servlet to the URL pattern "/display1".
Step 6:End the program.
_____________________________________
9. AIM:
Write a program in JSP by using session objects.
ALGORITHM:
Step 1: Start the process.
Step 2: User inputs their name in the HTML form (index.html).
Step 3: Upon submitting the form, the name is sent to session.jsp.
Step 4: In session.jsp:
a. The entered name is retrieved.
b. A welcome message is displayed with the entered name.
c. The name is stored in a session variable.
d. A link to output.jsp is provided.
Step 5: In output.jsp:
a. The stored name is retrieved from the session variable.
b. A greeting message is displayed using the retrieved name.
Step 6: End the program.
_____________________________________
10. AIM:
ALGORITHM:
Server Side:
Step 1: Define an interface (adder) that extends Remote with add that throws
RemoteException.
Step 2: Implement a class (server) that implements the adder interface and extends
UnicastRemoteObject.
Step 3: Write the add method in the server class to perform addition of two numbers.
Step 4: In the main method of the server class:
a. Create a registry on a specified port using LocateRegistry.createRegistry().
b. Bind the server object to the registry with a specific name using reg.rebind().
Client Side:
Step 1: Create a client class (client).
Step 2: In the main method of the client class:
a. Connect to the registry on the server's IP address and port number using
LocateRegistry.getRegistry().
b. Look up for the remote object by the name it was bound to on the server side using
reg.lookup().
c. Get user input for two numbers.
d. Cal l the add method on the remote object, passing the input numbers.
e. Display the result.
_____________________________________
11. AIM:
ALGORITHM:
Step 1: Start the program.
Step 2: Set up the calculator layout with a display showing "0" and buttons for digits and
operators.
Step 3: Handle button clicks:
- If a digit button is clicked:
- If it's the first digit, display it.
- If it's not the first digit, append it to the existing number.
- If an operator button is clicked:
- If it's not the first digit, perform previous operation and update the display.
- Remember the operator clicked.
- Return true to indicate the action was handled.
Step 4: Perform calculations:
- If '=', update the saved value with the current value.
- If '+', add the current value to the saved value.
- If '-', set the saved value to the current value.
- If '*', multiply the saved value by the current value.
- If '/', divide the saved value by the current value.
- Update the display with the result.
Step 5: End the program.
_____________________________________
12. AIM:
Program to send a text message to another system and receive the text message from the
system by using socket programming.
ALGORITHM:
Server-Side Algorithm:
Step 1: Start the server program.
Step 2: Listen for incoming connections on port 4999.
Step 3: Accept a connection from a client.
Step 4: Read a message from the client.
Step 5: Print the received message from the client.
Step 6: Send a response message to the client.
Step 7: Close the connection.
Step 8: End the server program.
Client-Side Algorithm:
Step 1: Start the client program.
Step 2: Connect to the server running on localhost and port 4999.
Step 3: Send a message to the server.
Step 4: Receive a response message from the server.
Step 5: Print the received message from the server.
Step 6: Close the connection.
Step 7: End the client program.
_____________________________________