answersLogoWhite

0

Write a java program in servlets?

User Avatar

Kodhand

Lvl 1
13y ago
Updated: 8/18/2019

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import javax.servlet.ServletException;

import java.io.PrintWriter;

import java.io.IOException;

public class OurFirstServlet extends HttpServlet

{

public void service(HttpServletRequest request,

HttpServletResponse response)

throws ServletException, IOException

{

response.setContentType("text/HTML");

PrintWriter out = response.getWriter();

out.println("< HTML >");

out.println("< head >< title >Servlet Example " +

" ");

out.println("< body >");

out.println("Not Much code, but this is enough for a Servlet.");

out.println("");

out.println("");

}

}

The above is a simple Servlet. It would display an almost blank HTML page that contains the message we put in "Not Much code, but this is enough for a Servlet."

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

How To write a java program to create three tier applications using servlets?

barsanabegam


Write a program in java to display a string message using Servlets?

i dont no string for servlate


What has the author Andrea Steelman written?

Andrea Steelman has written: 'Murach's Java servlets and JSP' -- subject(s): Java (Computer program language), JavaServer pages, Servlets


What has the author Marty Hall written?

Marty Hall has written: 'More servlets and JavaServer pages' -- subject(s): Active server pages, Java (Computer program language), Servlets


Is the JDK suitable for developing programs based on servlets in Java?

Yes. It is very suitable and in fact Servlets are based on the Java Technology and the Java Development Kit (JDK) is used for the same


Can we add website link when we write java program?

yes ,i can add the website link in java program when we write.


Is j2ee servlet development kit useful for developing servlets in j2se?

J2SE stands for Java 2 Standard Edition and I dont think Servlets are a part of it. Servlets are only part of the Java 2 Enterprise Edition.


How do you import others codes in java?

using servlets, php, and database we can connect import codes into java


Write a c program Fibonacci series using for loop in java?

Exactly what do you mean by 'C program in Java'


How are jsps betten than servlets?

JSPs can contain HTML, JavaScript, XML and Java Code whereas Servlets can contain only Java Code, making JSPs more flexible and powerful than Servlets. However, Servlets have their own place in a J2EE application and cannot be ignored altogether. They have their strengths too which cannot be overseen.


What is javadoc?

write a java program to display "Welcome Java" and list its execution steps.


How write new line program in java?

\n