0% found this document useful (0 votes)
444 views2 pages

Practical 21

The document describes a servlet program that prints 'Hello MSBTE' in an HTML page displayed in the browser. The program uses a servlet class that overrides the doGet method to set the content type and character encoding, get a PrintWriter, and output HTML to display the message.

Uploaded by

shrub125io
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)
444 views2 pages

Practical 21

The document describes a servlet program that prints 'Hello MSBTE' in an HTML page displayed in the browser. The program uses a servlet class that overrides the doGet method to set the content type and character encoding, get a PrintWriter, and output HTML to display the message.

Uploaded by

shrub125io
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/ 2

Advance Java Programming [22517] Practical Number: 21

Practical 21: Develop servlet program to


print Hello MSBTE in browser window

Program:-

package Servlet;

import jakarta.servlet.ServletException;

import jakarta.servlet.annotation.WebServlet;

import jakarta.servlet.http.HttpServlet;

import jakarta.servlet.http.HttpServletRequest;

import jakarta.servlet.http.HttpServletResponse;

import java.io.*;

public class practical_21_a extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse


response)

throws ServletException, IOException {

response.setContentType("text/html");

response.setCharacterEncoding("UTF-8");

PrintWriter out = response.getWriter();

out.println("<html>");

out.println("<head><title>Hello MSBTE</title></head>");

out.println("<body>");

Rushikesh Shrimanwar Page 1


Advance Java Programming [22517] Practical Number: 21

out.println("<h1>Hello MSBTE</h1>");

out.println("</body>");

out.println("</html>");

out.close();

Output:

Rushikesh Shrimanwar Page 2

You might also like