Write a servlet which accepts client request and display the client requested data on the browser?

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class DataServ extends HttpServlet {
 public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
  PrintWriter pw = res.getWriter();
  String name = req.getParameter("persdata_eurn");
  String cname = req.getParameter("persdata_eurc");
  pw.println("<center><h3>HELLO..! Mr/Mrs. " + name + "</h3></center>");
  pw.println("<center><h3>Your COURSE is " + cname + "</h3></center>");
 public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
  doGet(req, res);


1. Whenever we are not entering the data in html form that data will be treated as empty space.
2. Query string represents the data which is passed by client to the servlet through html form. URI stands for Uniform Resource Indicator which gives the location of servlet where it is available. URL stands for Uniform Resource Locator which gives at which port number, in which server a particular JSP or servlet is running. ht represents a context path which can be either a document root or a war file.