Advanced Java Programming - Old Questions
Question Answer Details
10. Write a Java program using servlet to display "Tribhuvan University". (5)
Answer
AI Generated Answer
AI is thinking...
Official Answer
import java.io.*;
import javax.servlet.*;
public class TU extends GenericServlet{
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException{
res.setContentType(“text/html”);
PrintWriter pw = res.getWriter();
pw.println("<html>");
pw.println("<head>");
pw.println(“<title>TU</title>”);
pw.println("</head>");
pw.println("<body>");
pw.println("<h2>Tribhuvan University</h2>");
pw.println("</body>");
pw.println("</html>");
pw.close();
}
}