[go: up one dir, main page]

0% found this document useful (0 votes)
21 views4 pages

AIP1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 4

EXPERIMENT -01

Student Name: kundan kumar UID: 23MCA20390


Branch: MCA Section/Group: MCA-2-B
Semester: 2nd semester Date of Performance: 29 Jan,2024 Subject Name:
Advance I P

subject Code:23CAH--551

1. Aim/Overview of the practical:

Create a simple client server communication application while creating a


HTML with form and two input fields like First Name and Last Name.
Submit the data to a servlet where the form data is retrieved and
displayed. Create form with GET method and another with POST
method.

Index.html
<!DOCTYPE html>
<!--
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/Html.html to edit this template
-->
<html>
<head>
<title>EXE 01 AIP</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form action="NewServlet" >
<label for="firstName">First Name:</label>
<input type="text" name="firstName" id="firstName" required>
<br>
<label for="lastName"> Last Name:</label>
<input type="text" id="lastName" name="lastName" required>
<br><br>
<input type="Submit" value="Submit">
</form>
</body>

Web.xml

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/Servlet.java to edit this template */

import java.io.IOException; import


java.io.PrintWriter; import
javax.servlet.ServletException; import
javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import
javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse;

/**
*
* @author Alok
*/
@WebServlet(urlPatterns = {"/NewServlet"})
public class NewServlet extends HttpServl

protected void processRequest(HttpServletRequest request, HttpServletResponse response)


throws ServletException, IOException {
String name = request.getParameter("firstName"); response.getWriter().append("my name is KUNDAN \n
my uid 23MCA 20390 \n my departmeant MCA (UIC)");
}

.Java File:

You might also like