Site icon WebArtDeveloper

How to work with HTML tags in Advance Java (J2EE)

In this tutorial how to work with HTML tags in Advance Java (J2EE) is shown.

Code:

index.html

<html>
<head>
<title>Wish Program</title>
<meta charset=”UTF-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
</head>
<body>
<form action=”Wish” method=”POST”>
<input type=”submit” value=”Click Here”>
</form>
</body>
</html>

Wish.java

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Wish extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType(“text/html;charset=UTF-8”);
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
out.println(“<!DOCTYPE html>”);
out.println(“<html>”);
out.println(“<head>”);
out.println(“<title>Servlet Wish</title>”);
out.println(“</head>”);
out.println(“<body>”);
out.println(“<h1><font color=’green’>”+”Good Morning”+”</font></h1>”);
out.println(“<h2><font color=’red’>”+”Good Afternoon”+”</font></h2>”);
out.println(“<h3><font color=’blue’>”+”Good Night”+”</font></h3>”);
out.println(“</body>”);
out.println(“</html>”);
}
}

}

https://youtu.be/5MTutcd2iQI

Exit mobile version