0% found this document useful (0 votes)
2 views

Advanced Java procedure(2024)

The document outlines various programming tasks using Java, including creating servlets, JSP applications, and socket programming. Each task includes steps for setting up a web application project in NetBeans, creating necessary files, and executing the programs. The tasks range from displaying welcome messages to building a client-server application and handling form data.

Uploaded by

sreeee437
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Advanced Java procedure(2024)

The document outlines various programming tasks using Java, including creating servlets, JSP applications, and socket programming. Each task includes steps for setting up a web application project in NetBeans, creating necessary files, and executing the programs. The tasks range from displaying welcome messages to building a client-server application and handling form data.

Uploaded by

sreeee437
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

1.

Display a welcome message using servlet

Steps to create the Web Application Project:


 Open NetBeans software
 Choose File → New Project
 Select Java Web form the Project categories and Web Application form
the Projects, Click Next.
 Click Next.
 Click Finish.
 This will create the Project Structure.

Creating and executing the program:


 Right click the source package in the project tree structure.
 Select New → Servlet
 Enter the servlet name, for example WelcomeServlet, Click Finish
 This will create a servlet file with the given name. Enter the code we want to
execute
 Save the changes
 Select Run → Run File → Run WelcomeServlet.java
Result: Thus the program to display a welcome message using servlet was
executed.

2. Design a purchase order form using HTML form and servlet.

Steps to create the Web Application Project:


 Open Netbeans software
 Choose File → New Project
 Select Java Web form the Project categories and Web Application form
the Projects, Click Next.
 Click Next.
 Click Finish.
 This will create the Project Structure.

Creating and executing the program:


 Right click the source package in the project tree structure.
 Select New → Servlet
 Enter the servlet name, for example PurchaseOrderServlet, Click Finish
 This will create a servlet file with the given name. Enter the code we want to
execute
 Again, right click the source package in the project tree structure.
 Select New → HTML
 Enter the html file name, for example purchase_order_form, Click Finish
 This will create an html file with the given name. Enter the code we want to
execute
 Save the changes
 Select Run → Run File → Run purchase_order_form.html
Result: Thus the program to design a purchase order form using HTML form and
servlet was executed.

3.Develop a program for calculating the percentage of marks of a student using


JSP.
Steps to create the Web Application Project:
 Open Netbeans software
 Choose File → New Project
 Select Java Web form the Project categories and Web Application form
the Projects, Click Next.
 Click Next.
 Click Finish.
 This will create the Project Structure.

Creating and executing the program:


 Right click the source package in the project tree structure.
 Select New → JSP
 Enter the jsp file name, for example marks, Click Finish
 This will create a new jsp file with the given name. Enter the code we want
to execute
 Again, right click the source package in the project tree structure.
 Select New → HTML
 Enter the html file name, for example marks, Click Finish
 This will create an html file with the given name. Enter the code we want to
execute
 Save the changes
 Select Run → Run File → Run marks.html
Result: Thus the program to develop a program for calculating the percentage of
marks of a student using JSP was executed.
4. Design a purchase order form using HTML form and JSP.
Steps to create the Web Application Project:
 Open Netbeans software
 Choose File → New Project
 Select Java Web form the Project categories and Web Application form
the Projects, Click Next.
 Click Next.
 Click Finish.
 This will create the Project Structure.

Creating and executing the program:


 Right click the source package in the project tree structure.
 Select New → JSP
 Enter the jsp file name, for example PurchaseOrderServlet, Click Finish
 This will create a jsp file with the given name. Enter the code we want to
execute
 Again, right click the source package in the project tree structure.
 Select New → HTML
 Enter the html file name, for example purchase_order_form, Click Finish
 This will create an html file with the given name. Enter the code we want to
execute
 Save the changes
 Select Run → Run File → Run purchase_order_form.html
Result: Thus the program to design a purchase order form using HTML form and
JSP was executed.

5. Prepare a employee pay slip using JSP.


Steps to create the Web Application Project:
 Open Netbeans software
 Choose File → New Project
 Select Java Web form the Project categories and Web Application form
the Projects, Click Next.
 Click Next.
 Click Finish.
 This will create the Project Structure.

Creating and executing the program:


 Right click the source package in the project tree structure.
 Select New → JSP
 Enter the jsp file name, for example employee, Click Finish
 This will create a jsp file with the given name. Enter the code we want to
execute
 Again, right click the source package in the project tree structure.
 Select New → HTML
 Enter the html file name, for example employee, Click Finish
 This will create an html file with the given name. Enter the code we want to
execute
 Save the changes
 Select Run → Run File → Run employee.html

Result: Thus the program to prepare an employee pay slip using JSP was executed.

6. Write a program using JBDC for creating a table, inserting, deleting records and
list out the records.
Creating Database in MS Access:
 Open Access → Blank database → Type file name(database name) in the
textbox, for example Test
 Click Create
 Right Click on Table1 → design view
 Type the table name, for example address, Click OK.
 Then enter the field names and the required data types
 Right Click on address → save the table.

Creating connection to NetBeans and Database:


 Open control panel
 Select Administrative tools/Windows tools
 Click ODBC Data Sources (32-Bit)
 Go to System DSN → Add → Select Microsoft Access Driver
(*.mdb,*.accdb) → Finish.
 Enter the Data Source name (Test) → Select → select the file name, then
click ok.

Steps to create the Web Application Project:


 Open Netbeans software
 Choose File → New Project
 Select Java Web form the Project categories and Web Application form
the Projects, Click Next.
 Click Next.
 Click Finish.
 This will create the Project Structure.

Creating and executing the program:


 Right click the source package in the project tree structure.
 Select New → Java Class
 Enter the java class name, for example Database, Click Finish
 This will create a java file with the given name. Enter the code we want to
execute
 Save the changes
 Select Run → Run File → Run Database.java

Result: Thus the program using JBDC for creating a table, inserting, deleting
records and list out the records was executed.

7. Write a program using java servlet to handle form data.


Steps to create the Web Application Project:
 Open Netbeans software
 Choose File → New Project
 Select Java Web form the Project categories and Web Application form
the Projects, Click Next.
 Click Next.
 Click Finish.
 This will create the Project Structure.

Creating and executing the program:


 Right click the source package in the project tree structure.
 Select New → Servlet
 Enter the servlet name, for example MyAddress, Click Finish
 This will create a servlet file with the given name. Enter the code we want to
execute
 Again, right click the source package in the project tree structure.
 Select New → HTML
 Enter the html file name, for example input, Click Finish
 This will create an html file with the given name. Enter the code we want to
execute
 Save the changes
 Select Run → Run File → Run input.html

Result: Thus the using java servlet to handle form data was executed.

8. Write a simple servlet program to create a table of all the headers it receives
along with their associated values.

Steps to create the Web Application Project:


 Open Netbeans software
 Choose File → New Project
 Select Java Web form the Project categories and Web Application form
the Projects, Click Next.
 Click Next.
 Click Finish.
 This will create the Project Structure.

Creating and executing the program:


 Right click the source package in the project tree structure.
 Select New → Servlet
 Enter the servlet name, for example ShowRequestHeaders, Click Finish
 This will create a servlet file with the given name. Enter the code we want to
execute
 Save the changes
 Select Run → Run File → Run ShowRequestHeaders.java

Result: Thus the simple servlet program to create a table of all the headers it
receives along with their associated values was executed.

9.Write a program in JSP by using session object.


Steps to create the Web Application Project:
 Open Netbeans software
 Choose File → New Project
 Select Java Web form the Project categories and Web Application form
the Projects, Click Next.
 Click Next.
 Click Finish.
 This will create the Project Structure.

Creating and executing the program:


 Right click the source package in the project tree structure.
 Select New → JSP
 Enter the jsp file name, for example welcome, Click Finish
 This will create a servlet file with the given name. Enter the code we want to
execute
 Again, right click the source package in the project tree structure.
 Select New → JSP
 Enter the jsp file name, for example second, Click Finish
 This will create a jsp file with the given name. Enter the code we want to
execute
 Again, right click the source package in the project tree structure.
 Select New → HTML
 Enter the html file name, for example inputpage, Click Finish
 This will create an html file with the given name. Enter the code we want to
execute
 Save the changes
 Select Run → Run File → Run inputpage.html

Result: Thus the program in JSP by using session object was executed.

10. Write a program to build a simple Client Server application using RMI.
Procedure:

Step 1: Create a folder rmi


Step 2: Within that rmi folder store the following three files:
 Client.java
 Server.java
 ImplExample.java
Step 3: Open the first command prompt
Step 4: Enter the following commands
C:\Users\ADMIN>D:
D:\>cd rmi
D:\rmi>set path="C:\Program Files (x86)\Java\jdk1.6.0\bin"
D:\rmi>javac *.java
D:\rmi>start rmiregistry
D:\rmi>java Server
Step 5:” Server Ready” message will be displayed on the command prompt
Step 6: Open the second command prompt
Step 7: Enter the following commands
C:\Users\ADMIN>D:
D:\>cd rmi
D:\rmi>set path="C:\Program Files (x86)\Java\jdk1.6.0\bin"
D:\rmi>java Client
Step 8: Now look into the first command prompt (Server) that will display the
message
This is an Example RMI program

Result: Thus the program to build a simple Client Server application using RMI
was executed.

11. Create an applet for a calculator application.


Procedure:

Step 1: Enter the code in Notepad and save it as Calculator.java


Step 2: Open the command prompt
Step 3: Enter the following commands
C:\Users\ADMIN>D:
D:\>cd calc
D:\calc>set path="C:\Program Files (x86)\Java\jdk1.6.0\bin"
D:\calc>javac Calculator.java
D:\calc>appletviewer Calculator.java
Step 4: The Calculator will be displayed on the screen

Result: Thus the program to create an applet for calculator application is executed.
12. Write a Program to send a text message to another system and receive the text
message from the system (use socket programming)
Procedure:

Step 1: Enter the code in Notepad and save it as MyClient.java and MyServer.java
Step 2: Open the first command prompt
Step 3: Enter the following commands
C:\Users\ADMIN>D:
D:\>cd mca
D:\mca>set path="C:\Program Files (x86)\Java\jdk1.6.0\bin"
D:\mca>javac MyClient.java
D:\mca>java MyClient
Step 4: Open the second command prompt
Step 5: Enter the following commands
C:\Users\ADMIN>D:
D:\>cd mca
D:\mca>set path="C:\Program Files (x86)\Java\jdk1.6.0\bin"
D:\mca>javac MyServer.java
D:\mca>java MyServer
Step 6: Send a text message from Server to Client. For example, hello
Step 7: The message was displayed in the Client page as “Server says: hello”
Step 8: Send a text message from Client to Server. For example, hi
Step 9: The message was displayed in the Server page as “Client says: hi”
Step 10: The conversation will be stopped when both the side receives the “stop”
message

Result: Thus the program to create an applet for a calculator application was
executed

You might also like